Jamey Graham | 26 Jun 2012 19:00
Picon
Favicon

NLS bundle format rules

Are there rules as to what constitutes a valid NLS bundle module?  I guess I (over) assumed that it could be any valid AMD module, but the following (simplified example..any syntax error is accidental), which is fine w/ dojo/i18n!, doesn't seem to get properly handled by the build system (1.7.3) -- should it?  I'd rather not discuss the "why's" here (this only represents the type of thing, not the actual thing) suffice to say i was looking to leverage i18n for localized messages AND behavior.

[foo/bar/nls/bundleWithDependenciesAndFactory.js]
define(['dojo/date/locale'],
function(dl) {
return {
root: {
msg: "Today is " + dl.format(new Date())
}
}});
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-interest <at> mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Kitson Kelly | 26 Jun 2012 19:17
Picon
Favicon
Gravatar

Re: NLS bundle format rules

This should apply to 1.7 and later: http://livedocs.dojotoolkit.org/dojo/i18n

It isn't perfect.  Our i18n documentation is really struggling at the moment, especially when it comes to dealing with it in builds.

The idea though is that the NLS bundle should only return string resources which then can be used in the application.  I don't think it was designed to actually be code which gets executed, so I don't know if you can use it for localised behaviour.  The behaviour aspect is interesting though, especially because language structure can differ quite a bit, meaning simple string substitution may not be the right way to display the appropriate information.  I don't think there is anything in DTK at the moment that deals with that though.

On 26 June 2012 18:00, Jamey Graham <jameyg228 <at> yahoo.com> wrote:
Are there rules as to what constitutes a valid NLS bundle module?  I guess I (over) assumed that it could be any valid AMD module, but the following (simplified example..any syntax error is accidental), which is fine w/ dojo/i18n!, doesn't seem to get properly handled by the build system (1.7.3) -- should it?  I'd rather not discuss the "why's" here (this only represents the type of thing, not the actual thing) suffice to say i was looking to leverage i18n for localized messages AND behavior.

[foo/bar/nls/bundleWithDependenciesAndFactory.js]
define(['dojo/date/locale'],
function(dl) {
return {
root: {
msg: "Today is " + dl.format(new Date())
}
}});

________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-interest <at> mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-interest <at> mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Adam Peller | 27 Jun 2012 19:10
Picon

Re: NLS bundle format rules


kitsonk wrote
> 
> The idea though is that the NLS bundle should only return string resources
> which then can be used in the application.  
> 

The intent was to be a subset, something like JSON, but even narrower in
scope: structures should not be nested, and typically only strings are used. 
This does need to be written up more clearly.  Without getting too much into
the "Whys," optimization tools could process these bundles prior to runtime,
so the actual behavior is uncertain (in this case, you'd get a fixed date
some time in the past, if it worked at all)  With AMD, dependencies and
behaviors like these may work, but I'd suggest staying away from them.

The typical way to do what you want is to use substitution, like "Today is
{0}".  That way, the behavior can be split out (in your app) and not
repeated for each locale, and the positioning is flexible.

-Adam

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/NLS-bundle-format-rules-tp3987073p3987101.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-interest <at> mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


Gmane