I've chosen a simple solution by creating a mixin for the application as
follows:
qx.Mixin.define("apple.application.MTranslation",
{
construct : function() {
qx.locale.Manager.getInstance().addListener("changeLocale",
this.loadApplicationTranslation, this);
this.loadApplicationTranslation();
},
members : {
loadApplicationTranslation : function() {
var locale = qx.locale.Manager.getInstance().getLocale();
if(locale) {
var map = this.getApplicationTranslationMap(locale);
if(map) {
qx.locale.Manager.getInstance().addTranslation(locale, map);
}
}
},
getApplicationTranslationMap : function(locale) {
var map = {
"item" : {
en : "apple",
de : "Apfel"
}
};
var m = {};
for(var id in map) {
if(map[id][locale]) {
m[id] = map[id][locale];
}
}
return m;
}
}
});
for the pears application the relevant part in getApplicationTranslation
(besides the pear namespace) would be:
var map = {
"item" : {
en : "pear",
de : "Birne"
}
};
To use this mixin simply add it to the include [...] list in your
Application.js like this:
qx.Class.define("apple.Application",
{
extend : qx.application.Standalone,
include : [
apple.application.MTranslation
],
...
I know that this way I'm loosing the automatism given by "generat.py
translation", having to track the this.tr/this.trn entries manually.
Any thoughts, hints, optimizations are very welcome.
Regards
Dietrich
Am 14.10.2015 um 15:02 schrieb Dietrich Streifert:
> Hi all!
>
> While generalizing common classes for different projects into
> contribs, I'm in need to have different translations for those
> contribs when used in different applications.
>
> Let's say I have a contrib named LIB, where I have a class using
> translation this way:
>
> var label = this.tr("item");
>
> Depending on the app using the contrib I want to translate different,
> optimally just by using differ *.po files for contrib LIB.
>
> This would be for the (just examples) the app "APPLES" the po entry:
>
> msgid "item"
> msgstr "apple"
>
> and the app "PEARS" the po entry:
>
> msgid "item"
> msgstr "pear"
>
> I've already found an old thread with a similar problem:
>
> http://qooxdoo.678.n2.nabble.com/library-translation-td4756389.html
>
> But that thread is 5 years old. So I'm hoping there is a solution for
> what I try to achieve.
>
> Regards
> Dietrich
>
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel