Feature #17368
closedAdd a second language fallback in sysext/lang/
0%
Description
Right now if a selected language is not available it goes to default.
In the future if we add "canadian french" or even "american english", it could be interesting to have this kind of fallback:
Canadian french(if not found) -> French(if not found) -> Default.
or
Spanish -> American english -> Default
For the record, there's lots of case in the "french" translation where the word "email" is used (instead of "courriel") and it's not acceptable in the context of government websites in Québec.
(issue imported from #M5759)
Files
Updated by Christian Wolff over 17 years ago
Absolutly right such a solution is needet.
in germans are different problems of this kind.
like German (de-de) Swoss-german (de-ch)
even knows a formal "Sie" an informal "Du" greeting form.
and it might be good to add this Translation types as well.
the fall back solution will be a good solution so only needet parts have to be translated.
Updated by Steffen Kamper over 17 years ago
To enable this it's like having categories in languages.
To use such a construct the xml-structure should be changed/extended
My idea is to use something like
<languageKey index="default" type="array">
<label index="register">register now</label>
<label index="registerlater">register later</label>
</languageKey>
<languageKey index="de" type="array">
<label index="register">Registrieren Sie sich jetzt</label>
<label index="registerlater">Registrieren Sie sich später</label>
<languageCat index="informal" type="array">
<label index="register">Registriere Dich jetzt</label>
<label index="registerlater">Registriere Dich später</label>
</languageCat>
<languageCat index="dialect" type="array">
<label index="register">chumm jez</label>
<label index="registerlater">lass es</label>
</languageCat>
</languageKey>
then a patch is need for additional option using languageCat (has to be set in TS, e.g.
config.language.languageCat = informal
with fallback if not exist ( to the default in the language section)
Updated by Jeff Segars over 17 years ago
Great idea. I can see many uses cases for language categories within a particular language.
With the Web-Empowered Church extensions, many churches use slightly different terms for the same things (ex: pastor, priest, minister). A feature like this would improve usability by presenting the editors terms that are most familiar to them.
Updated by Michael Stucki over 17 years ago
Just a little info on that: Though there are currently no plans to implement this in TYPO3, Robert Lemke has assured that this will be considered for 5.0.
Updated by Steffen Kamper over 17 years ago
ok, but this was not as difficult as i thought.
I made a patch where this can be used (with fallback)
The patch change 2 functions:
t3lib_div::readLLXMLfile
tslib_pibase::pi_getLL
I included a small demo extension to demonstrate the usage.
(diff is against last svn)
Updated by Steffen Kamper over 17 years ago
i forgot to remove a debug, so please use languageCategories2.diff
Updated by Michael Stucki over 17 years ago
Hi Steffen,
I had a quick look at your patch which looks promising and indicates that this change can be made quite simple.
However, I have the feeling that there is either something missing in your patch, or it is buggy. The reason for this assumption is that the only change in t3lib_div is this rename:
- function readLLXMLfile($fileRef,$langKey) {
+ function readLLXMLfile_($fileRef,$langKey) {
Since the rest of the changes are only made in tslib_pibase, I assume that you have only considered the frontend translation ($this->LOCAL_LANG). So what about backend translation?
Additionally, please consider that it is a bad idea to mix element values on different levels, as you did here:
$this->LOCAL_LANG[$this->LLkey][$key]
$this->LOCAL_LANG[$this->LLkey][$langCategory][$key]
and here:
$this->LOCAL_LANG_charset[$this->LLkey][$langCategory][$key]
$this->LOCAL_LANG_charset[$this->LLkey][$key]
After all I think that $langCategory should not be used at all. Instead the LLkey should be identical, like this is done for the Unix translation scheme: de_CH, de_DE, etc.
- michael
Updated by Steffen Kamper over 17 years ago
Hi Michael,
indeed there was something wrong in the diff. Sorry about that, it was wrong copying.
Now the patch3 is correct and shows my changes to t3lib_div.
The main thing i did was to enable 3rd level, so i expanded the foreach and evaluated to array or string.
If you use the xml-syntax i showed before you have the category in the array
label1
label2
label3
category.label1
category.label2
category.label3
So if it is a string, it's the default label, if it's an array its the label of the selected category.
Anyway this is only an option, without setting or using in xml you get same results as before.
I hope this makes it clear.
vg Steffen
Updated by Michael Stucki over 17 years ago
I think that the category should not be written into the label. This way, there is no separation of the translations at all. Austrians can change Swiss German words, etc.
If the language key was unique, there would be a translation for "Swiss German" with just a small set of words, and a pointer that the fallback language to this is "German German".
Your solution seems to be easy, but I have the impression it is not very future proof at all...
Updated by Michael Stucki over 17 years ago
And btw. could you please use tabulators in your patch, because this makes it a lot easier to review it... :-)
Updated by Steffen Kamper over 17 years ago
Hi Michael,
because the categories are "sublevel" they are in the place of the label when it is transformed to array. For me it seems logic that category is part of the language.
I don't think that this is a problem, using keywords for the category they don't have to be used as label itself, i don't see the problem of keeping them unique like "infomal,ch,at,..."
And sorry for the tabs, i use, but phpEd has strange formatting sometimes.
Updated by Dmitry Dulepov over 17 years ago
The more I think about it, the more I see it as language overlays. I.e. if we find:
<language index="de-ch">
We know that primary language is DE and overlay is CH. So we take DE first and put CH over it.
It will require support in core and llxml.
Updated by Steffen Kamper over 17 years ago
Hi Dmitry,
this would be an option too, and it would be "more easy" because only change is need in pi_getLL, something like
if(isset($this->LOCAL_LANG[$this->LLkey.'-'.$category][$key]) ...
Updated by Steffen Kamper about 17 years ago
ok, after some reflection time i did the way Dmitry proposed.
Definition of language category is the same:
config.language.category = informal
A sample of using in xml looks like this:
<data type="array">
<languageKey index="default" type="array">
<label index="term1">This is term1 (section default)</label>
<label index="term2">This is term2 (section default)</label>
<label index="term3">This is term3 (section default)</label>
<label index="term4">This is term4 (section default)</label>
<label index="term5">This is term5 (section default)</label>
</languageKey>
<languageKey index="default-informal" type="array">
<label index="term1">This is term1 (section informal)</label>
<label index="term2">This is term2 (section informal)</label>
<label index="term4">This is term4 (section informal)</label>
<label index="term5">This is term5 (section informal)</label>
</languageKey>
</data>
this is the default section only, it's the same with any language key, e.g.
config.language = de
then it will look to this entries as fallback:
de-informal => de => default-informal => default
To reach taht i had to patche same both files and same routines as before.
I excluded the section for external files in t3lib_div::readLLXMLfile, but this could be done in next step, if you agree with this patch.
I upload the new diff (languageCategories4.diff) and an update of working demo-extension.
Output of demo-extension can be viewed here:
http://www.sk-typo3.de/index.php?id=343
Updated by Steffen Kamper about 17 years ago
This is only for FE concerning pibase and LOCAL_LANG, I didn't looked for BE-translation so far.
I can look for BE-translation as well, but i have to examine the language class first.
Updated by Xavier Perseguers about 13 years ago
- Target version deleted (
0)
Please have a look at #29386 and report if we can close this feature request.
Updated by Alexander Opitz over 11 years ago
- Status changed from Accepted to Closed
No response in over one year => closed.