Usage of goog.getMsg & other i18n tools

1,002 views
Skip to first unread message

carsten

unread,
Jan 31, 2011, 11:49:01 AM1/31/11
to Closure Library Discuss
Hi all,

I did some research on the usage of goog.getMsg, but only found
possibly outdated info.
Could somebody please tell what the current status in the os version
of closure is?

1. is goog.getMsg supported by the compiler? (and if so, how do I pass
message files to it?)
2. how can the method getMsg actually be used?
3. how is code like goog.i18n.MessageFormat or goog.i18n.pluralRules
related/supported in the os version already?

Documentation on how to do translation for closure templates is
already provided here[1].
Would be great to have some guidance on how to use i18n with the
closure library, as well!

Thanks, Carsten

[1] http://code.google.com/closure/templates/docs/translation.html

Nick Santos

unread,
Jan 31, 2011, 6:30:32 PM1/31/11
to closure-lib...@googlegroups.com
On Mon, Jan 31, 2011 at 11:49 AM, carsten <carste...@gmail.com> wrote:
> Hi all,
>
> I did some research on the usage of goog.getMsg, but only found
> possibly outdated info.
> Could somebody please tell what the current status in the os version
> of closure is?
>
> 1. is goog.getMsg supported by the compiler? (and if so, how do I pass
> message files to it?)

Closure Compiler has a plugin api that lets you add a message bundle.
http://closure-compiler.googlecode.com/svn/trunk/javadoc/com/google/javascript/jscomp/MessageBundle.html
If you're using the compiler's Java API, setting the message bundle
should work just like any other compiler option.

Google has some proprietary translation formats with implementations
of MessageBundle. No one has contributed implementations for open
formats.

> 2. how can the method getMsg actually be used?

The compiler will replace the getMsg call with the translations in your bundle.

> 3. how is code like goog.i18n.MessageFormat or goog.i18n.pluralRules
> related/supported in the os version already?

you can set goog.LOCALE at compile-time with the flag
--define="goog.LOCALE=XX"
or by just modifying it locally.

If you're using advanced optimizations, the compiler will strip out
all the code for other locales.

carsten

unread,
Feb 1, 2011, 6:03:54 AM2/1/11
to Closure Library Discuss
Hi Nick,

thanks for the info!

On 1:
unfortunately we dont use the Java API, nor do we have a Java-savvy
developer around to try to make use of it.
Is it possible to use - manually extracted/edited - xliff files like
in Closure Templates?

Thanks again!
Carsten

On Feb 1, 12:30 am, Nick Santos <nicksan...@google.com> wrote:
> On Mon, Jan 31, 2011 at 11:49 AM, carsten <carsten.kr...@gmail.com> wrote:
> > Hi all,
>
> > I did some research on the usage of goog.getMsg, but only found
> > possibly outdated info.
> > Could somebody please tell what the current status in the os version
> > of closure is?
>
> > 1. is goog.getMsg supported by the compiler? (and if so, how do I pass
> > message files to it?)
>
> Closure Compiler has a plugin api that lets you add a message bundle.http://closure-compiler.googlecode.com/svn/trunk/javadoc/com/google/j...

Nicholas Albion

unread,
Oct 6, 2014, 9:46:23 AM10/6/14
to closure-lib...@googlegroups.com
Hi Nick,

Could you please provide more information on how goog.getMsg() is supposed to be used?

Bolin's book gives an example:

  /** @desc Label for the File menu. */
  var MSG_FILE_MENU = goog.getMsg('File');

The impression that I get is that when you run the compiler, it generates an XTB file that includes the @desc and support for placeholders within the string.  I suppose the solution is to use the "Messages" section at http://www.closurecheatsheet.com/skeleton (or for a Grunt build - https://github.com/janpanschab/grunt-xtb-generator)

Figuring out how to get the compiler to generate the XTB file would be the first part of the puzzle, the next part is how do we provide different translations - do we use the flag "--message_bundle=locale/messages-fr.xtb"?
Reply all
Reply to author
Forward
0 new messages