? Success

User tests: Successful: Unsuccessful:

avatar nonumber
nonumber
13 Feb 2014

Tracker: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33268

This adds the default behaviour to load the en-GB language file first as a base fall-back.

Currently the method loads the default language as base fall-back. But when the default language is not en-GB and there is no language file for the default language, then there will be no fall-back.

This has caused many extension developers, including myself, to implement an own extra $lang->load() call for en-GB first.

With this fix/addition, that will no longer be necessary.

This PR also changes the order of the checks in the if clause, placing the most simple and common checks first. The !$this->debug was placed first, whilst most website are not in debug mode. So that check should be last.

Testing instructions

Set the default language to something different than en-GB. Log into the admin with a different language than en-GB and not your default language (so you need at least 3 languages installed).
Then go to any view and make sure the language string for a certain text is not available for the language you are logged in with and also not for the default language (so it should only be available in the en-GB file).

Before this PR you should see the untranslated LANGUAGE_STRING. After this PR you should see the English (en-GB) translation for that string.

PS: You should of course not test this on a 3rd party extension view that has code to load the en-GB language as fall-back. There you should see no difference.

avatar nonumber nonumber - open - 13 Feb 2014
avatar jurianeven
jurianeven - comment - 13 Feb 2014

Sounds like good behaviour to me. Often this is forgotten.

You can extract !$this->debug from both if statements and wrap the statements with one !$this->debug check. It simplifies the code a bit and you'll get a tiny performance improvement.

Also the last if statement can then be simplified (first writing it out):
if ($default && $lang != $this->default && !$loadGB && 'en-GB' != $this->default)

Which can be simplified even more:
if ($default && !in_array($this->default, array($lang, 'en-GB')) && !$loadGB)

Maybe you can even simplify another step.

But would you'll need a flag for $loadGB? Why not always load it as a fallback? Something like this idea (code is incorrect for this PR, it's just about the idea):

$lang->load($this->component, $path, 'en-GB', true);
$lang->load($this->component, $path, null, true);
avatar nonumber
nonumber - comment - 13 Feb 2014

But would you'll need a flag for $loadGB? Why not always load it as a fallback?

Because some people that check new features always want to make sure there is an option to allow the old situation. Trying to be one step forward.

I'll change the ifs to make it more straight-forward.

avatar nonumber
nonumber - comment - 13 Feb 2014

Also the last if statement can then be simplified (first writing it out):
if ($default && $lang != $this->default && !$loadGB && 'en-GB' != $this->default)

No, that changes the behaviour. The way you suggest it, it would never pass if $loadGB is true. That's wrong.

avatar jurianeven
jurianeven - comment - 13 Feb 2014

Whoops, yes you're right.

avatar infograf768
infograf768 - comment - 13 Feb 2014

Not sure I get it. We do load en-GB first in 3.2.2 when debug is off.

Example: I set fr-FR as default admin language.

I take off from fr-FR.com_content.ini the string
COM_CONTENT_SUBMENU_FEATURED="Articles en vedette"

I take off the similar string from Italian language
COM_CONTENT_SUBMENU_FEATURED="Articoli in evidenza"

I log with Italian
=>The en-GB string is loaded and I get "Featured Articles"

screen shot 2014-02-13 at 16 56 32

This was implemented a while ago
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32496&start=0

  • a small correction later on
avatar nonumber
nonumber - comment - 13 Feb 2014

Hmm, seems there is a bug in the previous implementation then.
That loads the default, but the default is always en-GB. It is not set to the default language set in the site.

So yes, effectively it is already implemented that it loads the en-GB language first, but I wonder if that is how it was meant.

avatar infograf768
infograf768 - comment - 13 Feb 2014

yes, it is how we meant it, it loads en-GB first, not the default lang, same as FOF.

avatar nonumber
nonumber - comment - 13 Feb 2014

Ok, I'll close this.

Don't think the code actually reflects well enough what it is doing and it sets false expectations.
But I don't care.

avatar nonumber nonumber - change - 13 Feb 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-02-13 16:18:33
Labels Added: ?
avatar nonumber nonumber - close - 13 Feb 2014
avatar nonumber nonumber - close - 13 Feb 2014
avatar infograf768
infograf768 - comment - 13 Feb 2014

I agree the comment should be changed to reflect what the code does.

avatar nonumber nonumber - head_ref_deleted - 9 Apr 2014

Add a Comment

Login with GitHub to post a comment