[OpenLayers-Dev] status of translation possibilities

Erik Uzureau erik.uzureau at metacarta.com
Thu Oct 18 17:24:21 EDT 2007

On 10/18/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Thu, Oct 18, 2007 at 12:23:27PM -0500, Erik Uzureau wrote:
> > or maybe to keep the namespaces straight and clean, more like this:
> >
> > OpenLayers.Strings.languages['english'] = {
> >    'foo': "Foo for president",
> >    'bar': "Bar for gardner"
> > };
> This seems fine to me.
> > OpenLayers.String.setLanguage = function(lang) {
> >    OpenLayers.Strings.language = lang;
> > }
> setLanguage, if we're going to provide a method for it, is going to need
> to be more complex than that. We'd have to loop through the controls,
> and call redraw() on them, to update their text, and I'm not sure that
> all controls would support a redraw correctly.
> > OpenLayers.String.get = function(strKey) {
> >    return OpenLayers.Strings.languages[OpenLayers.String._language][strKey];
> > }
> It needs to be more complex than this to support interpolation, and I
> think it will need to: as the RFC says:
> "The OpenLayers.String object will have an additional function,
> translate. Translate will accept a translation key -- a single string
> which can be used to look up the string -- and any number of additional
> arguments. If additional arguments are passed, they will be interpolated
> in the string in order."
> MapBuilder already has some code that does this, so we can work with
> them to integrate those bits of it into OpenLayers.

ah... you mean, like printf stylie?

> It seems there is a general agreement that we need to do this. There are
> more technical details to work out:
>  * What is the expectation we provide for updating existing langauge
>    strings in the code? For example, controls will probably soon have
>    the ability to display titles in a control.panel object. However, the
>    title property is set on the div when it's created. Do we need to
>    make a redraw() that works for all controls that would use text? Does
>    this block integration of i18n support into core? (See also: CSS
>    support for display, which we didn't block on.)
>  * Do we block putting the library into core until we have all the
>    strings pulled out? (I think that given how little text we have, I
>    think this is 'yes'.)
>  * Do we block all future commits that include text on getting it using
>    the translation system? I think the answer to this is also yes.
> How far do we go before we put code in trunk?
> I think that some people who know more about i18n than me should start
> pondering all the things that an english speaker like me is going to
> screw up :) MapBuilder's experience here is, again, instructive.
> Regards,
> --
> Christopher Schmidt
> MetaCarta

More information about the Dev mailing list