[OpenLayers-Dev] status of translation possibilities

Erik Uzureau erik.uzureau at metacarta.com
Thu Oct 18 13:23:27 EDT 2007


or maybe to keep the namespaces straight and clean, more like this:


OpenLayers.Strings.languages['english'] = {
   'foo': "Foo for president",
   'bar': "Bar for gardner"
};

OpenLayers.String.setLanguage = function(lang) {
   OpenLayers.Strings.language = lang;
}


OpenLayers.String.get = function(strKey) {
   return OpenLayers.Strings.languages[OpenLayers.String._language][strKey];
}


and so:


OpenLayers.getString('foo');

or

OpenLayers.String.get('foo');


On 10/18/07, Erik Uzureau <erik.uzureau at metacarta.com> wrote:
> I like this idea a lot. we make a /lang directory and a separate file for
> each language. also the use of JSON I think is crafty.
>
> the file could look something like:
>
> OpenLayers.Strings['english'] = {
>     'foo': "Foo for president",
>     'bar': "Bar for gardner"
> };
>
> OpenLayers.String.setLanguage = function(lang) {
>     OpenLayers.String._language = lang;
> }
>
>
> OpenLayers.String.get = function(strKey) {
>     return OpenLayers.String[OpenLayers.String._language][strKey];
> }
>
>
> and so:
>
>
> OpenLayers.getString('foo');
>
> or
>
> OpenLayers.String.get('foo');
>
>
>
> this is off the top of my head.
>
>
> On 10/18/07, Dan Little <danlittle at yahoo.com> wrote:
> >
> > I wouldn't think this to be too hard.
> >
> > In most internationalized applications I've seen, there is typically a
> > "lang" or "strings" file that contains all of the strings for a given
> > application.  Then when the code needs a string it will call a global
> > variable containing that error/warning/info message.  This way all of the
> > needed translation is isolated to a single file.  Changing languages becomes
> > a matter of loading an alternate language file.
> >
> > So there could be a collection of language files:
> > strings.en.js
> > strings.es.js
> > strings.fr.js
> > strnigs.de.js
> >
> > And then provide some basic facilities for switching between them. In fact,
> > each of those files could be a JSON object that gets loaded to a global
> > object/variable.
> >
> > I may be just spewing bad ideas... but so long as the creative juices were
> > flowing I'd thought I'd share.
> >
> > -Duck
> >
> >
> > ----- Original Message ----
> > From: Jachym Cepicky <jachym.cepicky at gmail.com>
> > To: Bart van den Eijnden (OSGIS) <bartvde at osgis.nl>
> > Cc: "dev at openlayers" <dev at openlayers.org>
> > Sent: Thursday, October 18, 2007 8:58:42 AM
> > Subject: Re: [OpenLayers-Dev] status of translation possibilities
> >
> >  Bart van den Eijnden (OSGIS) píše v Čt 18. 10. 2007 v 15:44 +0200:
> > > Hi Chris,
> > >
> > > I think it is acceptable to have a global setting. I can't imagine a
> > > common use case (for myself) where one map would be in English and
> > > another one in Dutch on the same page. It is important though that it is
> > > possible to switch languages.
> > >
> > +1
> >
> > jachym
> >
> > > Best regards,
> > > Bart
> > >
> > > Christopher Schmidt schreef:
> > > > On Thu, Oct 18, 2007 at 03:23:50PM +0200, Jachym Cepicky wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> I would like to ask about the status of OpenLayers language support.
> > > >> There are not many strings, which could be translated, however, some
> > are
> > > >> there and IMHO we should (de)find a way, how to make this possible. Was
> > > >> there some discussion to this topic?
> > > >>
> > > >> IMHO, new map attribute "lang" should be defined, as well as new method
> > > >> OpenLayer.Util.getOLString("English text") (or similar).
> > > >>
> > > >> Any suggestions? Should I write something like this? Is there already
> > > >> some code out there?
> > > >>
> > > >
> > > > No code yet, but I agree that now is the time.
> > > >
> > > >
> > http://trac.openlayers.org/wiki/RFC/Internationalization
> > > >
> > > > Is my start at an RFC, which never went far enough.
> > > >
> > > > My belief is that we should make this a global setting, rather than a
> > > > per-map configuration. This would mean you could not have multiple
> > > > languages on the same page at the same time, but would also mean you
> > > > don't need a reference to the map object in order to get a correct
> > > > translation string. I don't know if the trade off is worth it. What do
> > > > other people think?
> > > >
> > > > Regards,
> > > >
> > >
> > >
> > --
> > Jachym Cepicky
> > e-mail: jachym.cepicky at gmail.com
> > URL: http://les-ejk.cz
> > GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > Dev mailing list
> > Dev at openlayers.org
> > http://openlayers.org/mailman/listinfo/dev
> >
> >
>


More information about the Dev mailing list