[OpenLayers-Dev] status of translation possibilities

Erik Uzureau erik.uzureau at metacarta.com
Thu Oct 18 17:29:41 EDT 2007


On 10/18/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Thu, Oct 18, 2007 at 03:46:21PM -0400, Paul Spencer wrote:
> >
> > On 18-Oct-07, at 2:31 PM, Christopher Schmidt wrote:
> >
> > >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.
> > >
> >
> > Could we use an event that is triggered and then controls that have
> > strings can register (or be registered) for the language changing?
> >
> > OpenLayers.String.events.register('languagechange',
> > OpenLayers.Function.bind(this, this.onLanguageChange));
>
> I like this idea. I hadn't thought of it, and it makes sense.

yes, i like it to. the only thing i dont like about it is that it
seems like it might sort of be a burden to control developers to have
to deal with registering events.

to that end, we might consider such a thing as making the base
OpenLayers.Control's constructor register the listener and call a stub
function udpateLanguage() or something like that. In
OpenLayers.Control, the stub function would do nothing. Then if
controls _do_ wish to update on language changes, they need only
implement the updateLanguage().

This might help in the case of a control that is subclassed from
another control -- the updateLanguage() calls would be chained up,
instead of having to register a separate listener for each class.

I dunno. This is just the first thing that comes to mind... that as a
control developer it seems like kind of a PITA and or unnecessary
overhead to be registering more listeners.

--E


>
> > We will probably want a LanguageSwitcher control that sets the
> > language and tracks the current language too, mostly for testing and
> > development.
>
> I'm not convinced that we need that, but if it gets built as part of
> development, it would probably be useful.
>
> > We need a way of indicating what languages to support in any given
> > application, and of enumerating the supported languages through the
> > OpenLayers API.
>
> for (var key in OpenLayers.Strings.languages) {
>   alert(key);
> }
>
> > We need a way to extend the base set of translations with other,
> > application-specific translations.
>
> OpenLayers.Strings.languages['eng']['My Application String!'] = 'My
> application String!';
>
> OpenLayers.Strings.languages['spa']['My Application String!'] =
> '¡String Applicacion de mio!';
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>



More information about the Dev mailing list