Richard Hirner schrieb:
> Hello,
>
> I want to translate something I fetch from an RPC call:
>
> // ... inside a function of application.Gui ...
> var self = this;
> rpc.callAsync(function(result, exc) {
>   for (var i = 0; i < result.length; i++) {
>     var g_type = result[i][5];
>     switch (g_type) {
>       case "0": result[i][5] = self.tr("EC/MC"); break;
>     }
>   }
>   res_model.setData(result);
> }, "getXXXXXXX");
>
> But it is strange - instead of "EC/MC" (I don't have translations
> yet, I only want the app to be i18n-enabled), the table contains
> an empty cell. If i do an alert(result[i][5]) immediately after
> result[i][5] = self.tr("EC/MC"), it correctly shows "EC/MC". Also,
> result[i][5] = "EC/MC" correctly fills the table with "EC/MC". The only
> problem is that the translated string is replaced by an empty one as
> soon as the function() returns. I think this may be a scope problem.
> Is there a possibility to make the translated string survive the return?
> Or is it something very other?
>
>   
Hi Richard,

the return value of 'this.tr' 
<http://demo.qooxdoo.org/current/apiviewer/#qx.locale.MTranslation~tr> 
is a LocalizedString 
<http://demo.qooxdoo.org/current/apiviewer/#qx.locale.LocalizedString> 
with a toString method returning the translated string. You may have to 
write

self.tr("EC/MC").toString()


Best Fabian

-- 
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, 
Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to