Lines 35-41
Javascript Gettext - Javascript implemenation of GNU Gettext API.
Link Here
|
35 |
var gt = new Gettext(params); |
35 |
var gt = new Gettext(params); |
36 |
// create a shortcut if you'd like |
36 |
// create a shortcut if you'd like |
37 |
function _ (msgid) { return gt.gettext(msgid); } |
37 |
function _ (msgid) { return gt.gettext(msgid); } |
38 |
alert(_("some string")); |
38 |
alert(__("some string")); |
39 |
// or use fully named method |
39 |
// or use fully named method |
40 |
alert(gt.gettext("some string")); |
40 |
alert(gt.gettext("some string")); |
41 |
// change to use a different "domain" |
41 |
// change to use a different "domain" |
Lines 71-77
Javascript Gettext - Javascript implemenation of GNU Gettext API.
Link Here
|
71 |
return this.gt.gettext(msgid); |
71 |
return this.gt.gettext(msgid); |
72 |
}; |
72 |
}; |
73 |
MyNamespace.MyClass.prototype.something = function () { |
73 |
MyNamespace.MyClass.prototype.something = function () { |
74 |
var myString = this._("this will get translated"); |
74 |
var myString = this.__("this will get translated"); |
75 |
}; |
75 |
}; |
76 |
|
76 |
|
77 |
// ////////////////////////////////////////////////////////// |
77 |
// ////////////////////////////////////////////////////////// |
Lines 81-87
Javascript Gettext - Javascript implemenation of GNU Gettext API.
Link Here
|
81 |
function _ (msgid) { |
81 |
function _ (msgid) { |
82 |
return myGettext.gettext(msgid); |
82 |
return myGettext.gettext(msgid); |
83 |
} |
83 |
} |
84 |
alert( _("text") ); |
84 |
alert( __("text") ); |
85 |
|
85 |
|
86 |
// ////////////////////////////////////////////////////////// |
86 |
// ////////////////////////////////////////////////////////// |
87 |
// Data structure of the json data |
87 |
// Data structure of the json data |
Lines 1210-1216
It's still recommended to use the statically defined <script ...> method, which
Link Here
|
1210 |
|
1210 |
|
1211 |
=item domain support |
1211 |
=item domain support |
1212 |
|
1212 |
|
1213 |
domain support while using shortcut methods like C<_('string')> or C<i18n('string')>. |
1213 |
domain support while using shortcut methods like C<__('string')> or C<i18n('string')>. |
1214 |
|
1214 |
|
1215 |
Under normal apps, the domain is usually set globally to the app, and a single language file is used. Under javascript, you may have multiple libraries or applications needing translation support, but the namespace is essentially global. |
1215 |
Under normal apps, the domain is usually set globally to the app, and a single language file is used. Under javascript, you may have multiple libraries or applications needing translation support, but the namespace is essentially global. |
1216 |
|
1216 |
|