User tests: Successful: Unsuccessful:
When installing a language, the corresponding content language is automatically created and also an image ("flag") associated with it.
However the logic for the language flags applied there is no proper logic at all: The issue is that there exists no language flags, they are country (or district) flags.
When a new official language is created by our translation teams, we manually have to upload a new image matching the new language code. For example for the german dialects this was done in a PR (see #11868).
Original PR was #12014. Feel free to read through the lengthy discussion there.
This PR suggest to change the logic and assign the flags based on the country code in our language codes. Eg for de-CH (Swiss German) it would take the image ch.gif instead of de-ch.gif.
To still allow language specific images, it will first look for an existing file with the language code and fall back to the country code.
This PR also removes all now unneeded (since duplicated) files and renames some:
33 files are renamed to their corresponding country code.
75 files are deleted because they were duplicates and are no longer needed.
6 files are renamed to a name which already existed with a wrong image before. Those are si.gif, ca.gif, br.gif, be.gif, at.gif and af.gif. This accounts for a small B/C break for people who used those images before, as they will now change. Solution is simple: The user needs to select the image fresh in the content language.
None that I am aware of.
Status | New | ⇒ | Pending |
Category | ⇒ | Repository NPM Change |
Suggestion:
Set to empty the image if none is available.
$image = strtolower(str_replace('-', '_', $tag));
if (!file_exists(JPATH_ROOT . '/media/mod_languages/images/' . $image . '.gif'))
{
// Use country (eg "gb") as the image.
$image = strtolower(substr($tag, strpos($tag, '-') + 1));
// Set to none if no image is available
if (!file_exists(JPATH_ROOT . '/media/mod_languages/images/' . $image . '.gif'))
{
$image = '';
}
}
Ah, good find. Will do that today!
For updates I would not delete the now unneeded files. If we delete them a lot more users would face a B/C issue which isn't needed at all. So for updates we also don't have to change the SQL.
@wilsonge Is it possible to exclude this folder from your script which collects removed files?
By not removing images only on new installs you create a scenario whereby on one site (an upgrade) you select a flag of de_DE.gif and on another site (clean install) you select a flag of de.gif
On the other hand for upgraded sites that have been set to use de_DE.gif and you do remove the image on upgrade then you get a 404 on the image.
By not removing images only on new installs you create a scenario whereby on one site (an upgrade) you select a flag of de_DE.gif and on another site (clean install) you select a flag of de.gif
Which is no problem. Or do I miss something?
Labels |
Added:
NPM Resource Changed
?
|
Updated with findings from JM
Which is no problem. Or do I miss something?
I am not a fan of different settings based on an upgrade or a clean install - personal opinion - others may disagree
@wilsonge Is it possible to exclude this folder from your script which collects removed files?
Yes. Add it into this array and we are good https://github.com/joomla/joomla-cms/pull/25559/files#diff-364166631f7d7383b58d579f097b86a2R63
I tested with Persian which worked but when I try to install for example fr-CA, en-us,... the language packages can't be found ...?
iirc at the moment there are only 3 languages ready for j4
french , german and persian
ping @infograf768 for confirmation
They are not "ready" for J4. Their 3.9 versions are only available for installing in J4 at J4 install time and through the Install Languages interface.
This was decided quite a while ago, to be able to test multiligual sites and RTL display in J4.
I have tested this item
J! 3.9.16
There are not enough languages to test this successfully. Ideally, we should be able to install a language available for different countries. For instance, French from France and French from Canada. Depending on the language file installed, we should get either the French flag or the Canadian flag.
@obuisard
You can install any language by fetching the packs on joomlacode and install as an extension.
http://joomlacode.org/gf/project/jtranslation3_x/frs/
You could manually download a package and install that zip like a regular extension.
The list of languages is here: https://community.joomla.org/translations/joomla-3-translations.html. French Canada here: http://joomlacode.org/gf/project/jtranslation3_x/frs/?action=FrsReleaseBrowse&frs_package_id=6871
Codewise it is the exact same thing that happens.
Oh, JM was faster
Thank you!
I tested now and I don't understand.
Before the patch I installed de-ch - created an article, applied de-ch to it. The language flag was de-ch.gif, afterwards I applied the patch and installed en-aus, en-us, ... and the image was en-aus.gif, en-us.gif ,... As far as I understood the test instructions it should be us.gif and so on after applying the patch ?
@coolcat-creations
If you use patchtester, it may not fully work.
I can't also fully apply the patch with eclipse, i.e. the .gif are not renamed and existing .gif to be deleted are not deleted.
The only way in this case to test the PR is to install @Bakual branch https://github.com/Bakual/joomla-cms/archive/40_UseCountryFlag.zip
Aye, it doesn't delete existing images to keep being backward compatible.
So since de-ch and en-us still exist in your folder, it will take those.
If you manually delete the de-ch or en-us files prior to create the respective language, you should see it pick the ch or us file instead.
Maybe I'm a bit late to the party, but I was pointed to this by the bugs and fun at home PR list.
2 questions:
Because languages don't match national borders, I think this PR is right. I will test it as soon as the conflicts are resolved.
I still think this PR would be useful. But I certainly don't have time to fix conflicts during the next week. However the conflict itself is minimal and easy to solve as it's only in the postgresql file (which has almost no impact).
A decision would certainly be welcome.
Labels |
Added:
Conflicting Files
|
Conflicts solved.
I tested the following:
git fetch origin pull/28575/head:40_UseCountryFlag
git checkout 40_UseCountryFlag
git reset --hard
HEAD is now at 794fad4 Merge branch '4.0-dev' into 40_UseCountryFlagcomposer install
and npm ci
build/media_source/mod_languages/images/
and in the media folder for mod_language. For German language I see only de.gif (no de_de.gif, de_ch.gif or de_at.gif).Then
System Information
php: Linux astrid-TravelMate-5760G 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64
dbserver: mysql
dbversion: 5.7.31-0ubuntu0.18.04.1
dbcollation: utf8_general_ci
dbconnectioncollation: utf8mb4_general_ci
dbconnectionencryption:
dbconnencryptsupported: true
phpversion: 7.2.31-1+ubuntu18.04.1+deb.sury.org+1
server: Apache/2.4.29 (Ubuntu)
sapi_name: apache2handler
version: Joomla! 4.0.0-beta4-dev Development [ Mañana ] 29-July-2020 18:21 GMT
useragent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0
I have tested this item
Labels |
Removed:
Conflicting Files
|
Merged current 4.0-dev so hopefully tests pass
I have tested this item
Tested successfully
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
I am closing this, seems not the perfect solution. Good would be a migration script that let us not have a b/c break. Thanks for the discusion and work on this.
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-18 19:11:50 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
?
|
p.s.
RLDQ
Clean install from your branch: problems for en-GB

needs change from
en_gb
togb
in base.sql as well as in update I guess.