? ? Pending

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
11 Jan 2018

When I tried to use the GitHub integration of Crowdin, I faced the issue that Crowdin can't rename part of the translated filename. Eg it can't rename the source file en-GB.com_weblinks.ini to de-DE.com_weblinks.ini. It can however change the foldername easily, eg /language/en-GB/ can be changed to /language/de-DE/.

That made me question the need for the language prefix.
Since we already have the language specific in the folderstructure, there is no technical reason to add it also to the filename.

Summary of Changes

This PR changes the JLanguage logic so it first tries to load the file with prefix and if that fails it tries again with a non-prefixed filename.
This works for all files except the en-GB.ini (.ini doesn't make much sense) one and the ones in the override folder (we need the prefix here to differentiate the files).

This PR also removes some fallback code that tries to load the file from the default (en-GB) language. However since a few years we already do the same thing before even trying to load the real file. So those fallback strings are already loaded and that code did just load the same strings again.

Testing Instructions

  • Try renaming eg the language files from com_banners from de-DE.com_banners.ini to just com_banners.ini and see if the translation still works.
  • Try removing the files and see that you get the english fallback strings.
  • Make sure all untouched files still work (eg com_content) as before
  • Test overrides (eg using Language Override Manager)

Expected result

With this PR, everything should work as before, even when renaming the files.

Actual result

Without this PR you get the english fallback strings when you rename a file.

Points for Discussion

  • Do we want to rename the en-GB.ini file? For Crowdin it doesn't matter, it can rename that one since it can replace the full filename.
  • Do we want to deprecate the prefixed language files? If so, we need to communicate that early as it would impact language packs as well as every extension out there.
    Personally I would certainly keep it for 4.0 but it may be something to be removed for 5.0 but I don't think it's worth the trouble. The code to keep it both ways is quite simple.

Documentation Changes Required

Documentation regarding translations need to be adjusted.

avatar Bakual Bakual - open - 11 Jan 2018
avatar Bakual Bakual - change - 11 Jan 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Jan 2018
Category Libraries
avatar Bakual
Bakual - comment - 11 Jan 2018

For those wondering how Crowdin integrates GitHub, I have setup a test project for the Weblinks extensions: https://crowdin.com/project/joomla-weblinks-extension

The result is Bakual/weblinks#2 which is all done by Crowdin itself automatically.

avatar mbabker
mbabker - comment - 11 Jan 2018

When I tried to use the GitHub integration of Crowdin, I faced the issue that Crowdin can't rename part of the translated filename.

This is basically why even when trying to use Crowdin's native CLI functionality I ended up publishing https://github.com/joomla-projects/crowdin-sync instead (making use of the same YAML config file). Through its tooling there just isn't a way to get the files downloaded with the correct name, but with the API you can manipulate the data to build the right file paths.

Removing the locale code from the filenames simplifies a lot of things in the long run IMO.

avatar brianteeman
brianteeman - comment - 11 Jan 2018

i guess that the en-GB.ini could be renamed as joomla.ini

avatar Bakual
Bakual - comment - 11 Jan 2018

i guess that the en-GB.ini could be renamed as joomla.ini

From a code point of view, that actually would make sense as it makes the code simpler. We could get rid of the check $internal = $extension == 'joomla'.

avatar ot2sen
ot2sen - comment - 11 Jan 2018

Am in two minds about this one. Can see how it could ease things at a technical level. At the same time it looks like trouble leaving out the unique identifier for all the people dealing with language maintenance beyond one language.

When you work in a role as language coordinator, translation maintainer or the like, there would be a great mix of how your staff or volunteers would prefer to work with the language sets, the tools they use and how they deliver them back for use. Cutting out the file naming identifier could make such maintenance more troublesome. Having a visible file prefix identifier is rather helpful when dealing with multiple languages (2 -> +50)
Not sure if it is the dot separator causing the trouble for this specific crowdin case, if so perhaps an underscore change would solve that? (en-GB_com_extension.ini)

Another concern would be when installing multiple languages with an extension and making use of system wide language folders and also of in extension level language folders, to have different messages in the sys.inis for installation message and for the edit extension main message. Here you could have an install folder with multiple languages that are prefixed in same folder, and this would be a problem should they all lack their unique xx-XX identifier.

avatar mbabker
mbabker - comment - 11 Jan 2018

Not sure if it is the dot separator causing the trouble for this specific crowdin case, if so perhaps an underscore change would solve that?

It's not the dot separation. You upload a file as en-GB.com_extension.ini, regardless of the language you are downloading as you get a file named en-GB.com_extension.ini unless you write custom tooling like the one I'm using for various projects to automate fixing the locale code. This is a Crowdin problem in general (we have the same type of tooling workaround in the issue tracker which isn't using the Joomla Language API).

Another concern would be when installing multiple languages with an extension and making use of system wide language folders and also of in extension level language folders

Not a concern with the design of our language system. It enforces a <APPLICATION_OR_EXTENSION_ROOT>/language/<code>/<code>.<extension>.ini filesystem structure, making it impossible to put files of multiple languages into one directory.

avatar infograf768
infograf768 - comment - 12 Jan 2018

i guess that the en-GB.ini could be renamed as joomla.ini

From a code point of view, that actually would make sense as it makes the code simpler. We could get rid of the check $internal = $extension == 'joomla'.

In that case, it should not be limited to en-GB obviously.

avatar Bakual
Bakual - comment - 12 Jan 2018

In that case, it should not be limited to en-GB obviously.

Not sure what you mean. Do you mean it has to be done for the other languages as well? If so, then yes.
It certainly needs a time where both variants are supported as well. Eg during 4.0 we allow both "joomla.ini" and "en-GB.ini" (or eg de-DE.ini), and with 5.0 it has to be joomla.ini.
That would give translators ample time to rename the file. Do you think that would work?

@ot2sen I understand that it might be harder to differentiate the files, but I think that could be solved by adjusting the workflow slightly. Eg put the files into subdirectories/zips with the proper language code.
On the other hand, you no longer have to rename the files when copying the english files to a new language. Or when copying the files to a dialect of the same language (eg de-DE to de-CH).

avatar infograf768
infograf768 - comment - 12 Jan 2018

Some thoughts

  1. The patch works fine
  2. I agree with some aspects of @ot2sen remarks. I am concerned, as he is, about the impossibility to differentiate the files when a Team is exchanging files in various languages.
  3. There is also an aspect which I find troublesome is the fact that it is Joomla which has to adapt to Crowdin.
    I do understand that we evidently have to comply to W3C standards (including Accessibility) but in this case we make ourselves again dependent, code wise, from a closed source commercial system.
    Evidently I am known to be part of those that think Joomla should be as agnostic as possible to a lot of stuff, including bootstrap, but nevertheless...

Side Note:
concerning

On the other hand, you no longer have to rename the files when copying the english files to a new language. Or when copying the files to a dialect of the same language (eg de-DE to de-CH).

That is something com_localise does in a few clicks and then make the lang pack also in a few clicks. 😺

avatar Bakual
Bakual - comment - 12 Jan 2018

There is also an aspect which I find troublesome is the fact that it is Joomla which has to adapt to Crowdin.

Actually, I think other translation platforms may face the same issue if they have a GitHub integration.
Technically, there is no need for those prefixes as we have. I think this comes from history where maybe they all lived in the same folder in the beginning. If we would develop language support today, then we likely wouldn't add prefixes to the filenames.
But anyway, it's not strictly about Crowdin. It started there, yes, but my next thought was "Why do we even have this prefixes and could we do without to make things simpler and work also better with Crowdin". Sounded like a win-win to me so far.

That is something com_localise does in a few clicks and then make the lang pack also in a few clicks.

You could make the com_localise code simpler then as well. 😄

avatar infograf768
infograf768 - comment - 12 Jan 2018

I think this comes from history where maybe they all lived in the same folder in the beginning.

Just for history, they already did reside in xx-XX folders in 1.5.

avatar Bakual
Bakual - comment - 12 Jan 2018

True, and in 1.0 it was a /language/english.php file. So it was like this since the INI files were introduced.

avatar brianteeman
brianteeman - comment - 12 Jan 2018

All these "problems" are just "what ifs" and should never be an issue when using a robust workflow

avatar ot2sen
ot2sen - comment - 12 Jan 2018

@mbabker I probably wasn´t clear about the

Not a concern with the design of our language system. It enforces a <APPLICATION_OR_EXTENSION_ROOT>/language/<code>/<code>.<extension>.ini filesystem structure, making it impossible to put files of multiple languages into one directory.

where I meant within the installation package, not where it get installed.

Today you can have an installation XML like:

	<folder>language</folder>
</files>
<languages folder="lang">
    <language tag="en-GB">en-GB.plg_content_example.ini</language>
	<language tag="en-GB">en-GB.plg_content_example.sys.ini</language>
    <language tag="da-DK">da-DK.plg_content_example.ini</language>
	<language tag="da-DK">da-DK.plg_content_example.sys.ini</language>
	<language tag="it-IT">it-IT.plg_content_example.ini</language>
	<language tag="it-IT">it-IT.plg_content_example.sys.ini</language>
</languages>
<config><fields name="params"><fieldset name="basic" label="basic">


Actual content of /lang folder is listed side by side in the installation package:
/lang
en-GB.plg_content_example.ini
en-GB.plg_content_example.sys.ini
da-DK.plg_content_example.ini
da-DK.plg_content_example.sys.ini
it-IT.plg_content_example.ini
it-IT.plg_content_example.sys.ini

and because of the tag they get installed correctly in their respective prefix folders under the site wide language folder.

Without the prefix you would have no way to tell which is which of the 3 double sets of files.
Could this be a matter of documentation to ensure they are placed in subfolders just as done at the installation package for those under language in same XML.
Just to have awareness that it is possible to have them side by side in an installation package today before installation, and this wouldn´t work when file prefixes are gone. Might not be a bad thing :)

avatar Fedik
Fedik - comment - 12 Jan 2018

Today you can have an installation XML like

but you also can have just <folder>language</folder> and do not worry about any prefixes 😉

avatar Bakual
Bakual - comment - 12 Jan 2018

@ot2sen Personally, I wouldn't remove the prefixes in J4.0 anyway. So you could still do that in 4.0. If we remove it in 5.0, then that would be no longer possible.
However as Fedik said, it's easier anyway to just put the files into the respective subfolders and be done with a single folder tag.

avatar ot2sen
ot2sen - comment - 12 Jan 2018

@Fedik yeah, also did have the language in the example which would have subfolders with the prefixes within in the installation package. Those to go directly language folder inside the extension when installed, which is fine. The other /lang folder would have been more clear in purpose had I added just the sys.inis to demonstrate these are for having a different message for the user on installation finalisation. Anyway, it all comes down to habit of having done year of manual preparation. With automatisation it is not much of an issue ;)

@Bakual yep, workflow again. Automate with subfolders and it is not much of an issue. As I said in first post I do see how this can ease thing at the technical level. Dusting off the dinosaur and shaking off my manual habits. At the end of the day I like the suggestion :)

avatar mbabker
mbabker - comment - 12 Jan 2018

we make ourselves again dependent, code wise, from a closed source commercial system.

Honestly, having an opinion on this or making a decision shouldn't be 100% driven by Crowdin. With that said, just shooting from the hip here are how other systems handle filesystem structure.

Joomla: language/<locale>/<locale>.<extension>.ini
Symfony 4: translations/<extension>.<locale>.<file_format>
Laravel: resources/lang/<locale>/<extension>.php
Concrete 5: packages/<package>/languages/<locale>/LC_MESSAGES/messages.po

So Joomla's really the only system with a double locale code in its filesystem structure. Personally I'm not a fan of it but I see why it has benefits to some.

avatar laoneo
laoneo - comment - 4 Apr 2018

Should we not target that pr against 4 and rename the language files correctly without the double locale?

avatar Bakual
Bakual - comment - 4 Apr 2018

Since it's completely B/C, it can (and imho should) be merged into 3.9.
We should then rename the language files for 4.0 of course. But the support should be in 3.9 so extensions could work in both with non-prefixed files.

avatar laoneo
laoneo - comment - 4 Apr 2018

True.

avatar infograf768
infograf768 - comment - 4 Apr 2018

Is it really totally B/C? I have not tested with overrides. Has anybody done it? In overrides, the files are NOT separated by folders.

avatar mbabker
mbabker - comment - 4 Apr 2018

Considering the code loading and parsing overrides if found hasn't changed, then no, the overrides aren't broken (in part because it doesn't even use this same load method but bypasses it completely and goes straight to parse).

avatar Bakual
Bakual - comment - 4 Apr 2018

I actually tested overrides and they still work as expected. It's even mentioned as test case in the PR 😉

avatar infograf768
infograf768 - comment - 5 Apr 2018

Indeed, as the code concerning loading overrides ini has not changed, these are still working as are.

Suggestion: if we go this way then we may also create an array (on the model of localise.php) for
$filename = JPATH_BASE . "/language/overrides/$lang.override.ini";
to let load JPATH_BASE . "/language/overrides/$lang/override.ini

Some more remarks:
joomla.ini would work to replace en-GB.ini
something like (maybe also an array and KSort?)

		if ($internal)
		{
			$filenames[] = "$path/$lang.ini";
			$filenames[] = "$path/joomla.ini";  // NEW
		}
		else

---ADDED: Or check the existence of the file as done below for joomla.xml

Add this to the PR?

What would be the name in the future for en-GB.xml in the language packs? joomla.xml is already used as manifest.
My feeling is that we should first decide about all these aspects before merging this.

avatar laoneo
laoneo - comment - 5 Apr 2018

Should we target the pr against 3.9?

avatar brianteeman
brianteeman - comment - 5 Apr 2018

What would be the name in the future for en-GB.xml in the language packs? joomla.xml is already used as manifest.

Why cant you use joomla.xml - the path is unique still
But then why even rename the xml or ini

avatar infograf768
infograf768 - comment - 5 Apr 2018

But then why even rename the xml or ini

For the same reason this PR is created, i.e. to fit crowdin.

avatar infograf768
infograf768 - comment - 5 Apr 2018

Found a way to use joomla.xml instead of xx-XX.xml.

requires modifying some stuff, for example in /administrator/components/com_languages/controllers/installed.php

		// Fetching the language name from the xx-XX.xml
		$file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
		
		if (!file_exists($file))
		{
			$file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/joomla.xml';
		}

and in languagehelper

				$metafile   = self::getLanguagePath($clientPath, $language->element) . '/' . $language->element . '.xml';
				
				if (!file_exists($metafile))
				{
					$metafile   = self::getLanguagePath($clientPath, $language->element) . '/joomla.xml';
				}

and

				$dirPathParts = pathinfo($directory);
				$file         = $directory . '/' . $dirPathParts['filename'] . '.xml';
				
				if (!file_exists($file))
				{
					$file = $directory . '/joomla.xml';
				}

I would have to look elsewhere for more changes but the principle would be the same i.e. checking for the file with lang prefix and if not look for the file with joomla

BTW, although this looks like working fully, I get a Notice in /libraries/src/Help/Help.php
Undefined offset: 1 in .../libraries/src/Help/Help.php on line 138

avatar mbabker
mbabker - comment - 5 Apr 2018

Personally I'd name it metadata.xml versus joomla.xml, at least then the filename actually gives a semi-useful clue about what kind of data it contains.

avatar infograf768
infograf768 - comment - 5 Apr 2018

Personally I'd name it metadata.xml versus joomla.xml, at least then the filename actually gives a semi-useful clue about what kind of data it contains.

no p. Code is similar. :) We can also be even more precise and use langmetadata.xml.

avatar Bakual
Bakual - comment - 5 Apr 2018

metadata or langmetadata is fine for me. en-GB.xml actually would work for Crowdin as well since we can substitute the whole filename (in this case en-GB). We just can't replace parts of the filename.

avatar Bakual
Bakual - comment - 5 Apr 2018

I can have a look at the suggested other changes as well. Makes sense to me.

avatar Bakual Bakual - change - 5 Apr 2018
Labels Added: ? ?
avatar joomla-cms-bot joomla-cms-bot - change - 5 Apr 2018
Category Libraries Administration com_languages Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 5 Apr 2018
Category Libraries Administration com_languages Administration com_languages Installation Libraries
avatar Bakual
Bakual - comment - 5 Apr 2018

I've updated this PR to include the following changes:

  • xx-XX.ini may now be named joomla.ini
  • xx-XX.xml may now be named langmetadata.xml

As you may have noted, this alone made this PR already quite a bit more complex as especially the XML part meant also some changes in the installer adapter. Hopefully I catched all of them.

I deliberately left off the suggested changes to the overrides. Changing that would mean also changes in the language override manager which would make this PR even more complex.
Also I'm not so sure if we need to change anything there. After all we don't have any double locale there like in the other places.

avatar infograf768
infograf768 - comment - 6 Apr 2018

I have tested this item successfully on 2d3f48c

Works fine here. No error for the help screens. tested for installation, admin, site.

Only remarked (but I guess this is to be expected) that when using debug we get for each file for which the prefix has been taken off (here for French)


**Non chargé** : JROOT/administrator/language/fr-FR/fr-FR.ini
**Chargé** : JROOT/administrator/language/fr-FR/joomla.ini
**Non chargé** : JROOT/administrator/language/fr-FR/fr-FR.lib_joomla.ini
**Chargé** : JROOT/administrator/language/fr-FR/lib_joomla.ini
**Non chargé** : JROOT/administrator/language/fr-FR/fr-FR.plg_system_updatenotification.ini
**Chargé** : JROOT/administrator/language/fr-FR/plg_system_updatenotification.ini
**Non chargé** : JROOT/administrator/language/fr-FR/fr-FR.plg_system_fields.ini
**Chargé** : JROOT/administrator/language/fr-FR/plg_system_fields.ini
**Non chargé** : JROOT/administrator/language/fr-FR/fr-FR.plg_system_logout.ini
**Chargé** : JROOT/administrator/language/fr-FR/plg_system_logout.ini

etc.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19353.
avatar infograf768 infograf768 - test_item - 6 Apr 2018 - Tested successfully
avatar Bakual
Bakual - comment - 1 Sep 2018

@mbabker Dou you want this in J3.9?

avatar mbabker
mbabker - comment - 1 Sep 2018

If it gets tested out before beta then sure.

avatar Bakual
Bakual - comment - 1 Sep 2018

Rebased PR. There were no conflicts so test by JM should still be good.
Drone complains about some JS stuff which this PR didn't touch. I've restarted the job once and it didn't fix the issue.

avatar zero-24
zero-24 - comment - 1 Sep 2018
avatar tecpromotion
tecpromotion - comment - 8 Sep 2018

I have tested this item successfully on 8e0a7fc

Tested this PR successfully.

I have randomly renamed some files in the folder /language/de-DE/administrator and /language/de-DE/

As an example, I first renamed the file language /de-DE/de-DE.com_contact.ini to x.com_contact.ini. It was used English as fallback. Then the file was renamed to com_contact.ini without a prefix and the contact component was successfully translated again.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19353.

avatar tecpromotion tecpromotion - test_item - 8 Sep 2018 - Tested successfully
avatar wilsonge
wilsonge - comment - 15 Jan 2019

This has been approved by Production after discussion with the translation team. If you could rebase this against the 3.10 branch we can get it merged :)

avatar joomla-cms-bot joomla-cms-bot - change - 15 Jan 2019
Category Libraries Administration com_languages Installation Repository Administration com_joomlaupdate com_languages Language & Strings
avatar Bakual Bakual - change - 15 Jan 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 15 Jan 2019
Category Administration com_languages Repository com_joomlaupdate Language & Strings Administration com_languages Installation Libraries
avatar Bakual
Bakual - comment - 15 Jan 2019

@wilsonge Rebased and changed base of PR. There were no conflicts.
I've merged some codestyle suggestions from @Quy. Only some superfluous spaces.

avatar Bakual Bakual - change - 17 Jan 2019
Title
[RFC] Add support for non prefixed language files
Add support for non prefixed language files
avatar Bakual Bakual - edited - 17 Jan 2019
avatar wilsonge wilsonge - change - 21 Jan 2019
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-01-21 18:21:48
Closed_By wilsonge
Labels Added: ?
Removed: ? ?
avatar wilsonge wilsonge - close - 21 Jan 2019
avatar wilsonge wilsonge - merge - 21 Jan 2019
avatar wilsonge
wilsonge - comment - 21 Jan 2019

Thanks for this!

avatar zero-24
zero-24 - comment - 29 Sep 2020

Add a Comment

Login with GitHub to post a comment