Use gettext for locale
Please before forming an opinion about this go get some information about it. There is one of the many implementation examples around the web http://www.pontikis.net/blog/php-java...ext-poedit, might seem tricky to implement at 1st but once it's done everything will come into place.
It's also safe for backwards compatibility as long as the infusions and themes use their own old locale files and variable references. Either way sacrificing such a great tool for localization just for backwards compatibility makes no sense.
To give you an idea about it, here is how a locale looks now
echo $locale['123']; // yea... no fkin' idea what this is it, better go open locales files find what it is
this is how gettext does it
echo _("Hello world!"); // it's pretty clear what this text is about
Go to roadmap item #1499
Also wanted to mention that there is also cross-platform tools like Poedit specifically developed for extracting and then translating the text making everything so much more easier. So all you have to do after developing something is to indicate to Poedit where .php source files are and it will search and extract the locale text lines automatically then all you have to do is to translate them and click save.
Oh and there will no longer have missing text and undefined variable indexes due to missing locales, if a translation for a string is not found the original string will simply be displayed. So if my website has Romanian set as locale and I have somewhere in the code
echo _("Hello world!");
but not the translated string in Romanian then
Is all words for languages in a flat file or something where are the words?
I mean if I code in...
echo _("Hello world!");
Where will it find the Romanian words for this?
My questions is administration interface. We need a core admin file if we do this.
So it could happen to translate wrong like Google Translate does 90% of the time in the wrong context?
Example: This bad is a translation very.
In that case, no. Leave locales the way they are. We discussed locales plenty in the past so there is already lots of nice ideas lying around or at least there was. Someone suggested 1 file for admin 1 file for front end. I say just leave it for now then when version 9 comes change the locale way big time to the simple solution not yet invented. All is good either way as long as it works nice eh.
ro_RO is the language and LC_MESSAGES must not change as is the standard
also there will be no en_US folder since the default language is in the code.
This is how a string is translated inside a .po file
msgid "Unknown system error"
msgstr "Eroare de sistem necunoscuta"
My ... the move would require us to update almost all files. :)
- we will have the plain default text directly in the code making it way more easier to read and what surrounding code is about [no more arrays and number keys]
- if a string is not translated the default EN string will be displayed [no more missing variable errors and missing text]
- has native support for plurals, you simply translate all the plural versions and in then add the code based on values you expect. Looks like this
file.po, we define in the header of the file how many plural versions a language has, Romanian has 3 and it looks like this
nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);
msgid "%d term"
msgid_plural "%d terms"
msgstr "%d termen"
msgstr "%d termeni"
msgstr "%d termene"
file.php, more details here http://www.php.net/manual/en/function.ngettext.php
printf(ngettext("%d term", "%d terms", 1), 1); // if just one termen
printf(ngettext("%d term", "%d terms", 2), 2); // if 2 termene
printf(ngettext("%d term", "%d terms", 20), 20); // if 20 termeni (this is incorrect grammatically but is just for demo)
- there are dedicated tools for translating the files, they automatically extract all the localized strings from source code
Keep in mind that I might be wrong about some things as all i explained you was not put in practice at all as I don't have the possibility at the moment, this is all from research. If you want to understand better gettext go google it and do research and testing.
But maybe not for v8.0. This could be a todo for v8.1. because you need to rewrite all files.
This rewrite will last weeks.
The problem with the missing Locals can be fixed temporary very easy:
Just my two cents
About implementation it's either done now in 1st 8 stable release or 9(?), it's quite a change and should be done in a major version.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.