[OpenLayers-Dev] tips for using i18n

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Mon Mar 10 10:38:07 EDT 2008


Hey Mike,

that example doesn't work for me against trunk. It overrides all the
existing keys in en and fr.

This does work:

var myEnglishStrings = {
'myTest': "these are user defined strings"
}

OpenLayers.Util.extend(OpenLayers.Lang.en, myEnglishStrings);

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl


--------- Oorspronkelijk bericht --------
Van: Mike Adair <madair at dmsolutions.ca>
Naar: Bart van den Eijnden OSGIS <bartvde at osgis.nl>
Cc: dev at openlayers.org
Onderwerp: Re: [OpenLayers-Dev] tips for using i18n
Datum: 10/03/08 11:26

> There used to be an i18n example file but perhaps that didn't make it to 
> trunk.  In any case, you can do this by just extending the 
> OpenLayers.Lang class, something like:
> 
>         var myStrings = {
>           en: {
>             myTest: 'these are user defined strings',
>             myTemplate: 'language code currently set to {0}'
>           },
>           fr: {
>             myTest: 'ceci est du text different: pardon mon français',
>             myTemplate: 'code de langage est fixé à {0}'
>           }
>         }
>         OpenLayers.Util.extend(OpenLayers.Lang, myStrings);
>        
> Mike
> 
> Bart van den Eijnden (OSGIS) wrote:
> &gt; Hi list,
> &gt;
> &gt; I am trying to use the OpenLayers i18n framework in my own
application. How
> &gt; can this be done? I.e. add extra strings to the dictionary.
> &gt;
> &gt; I want to keep the strings outside of the OL dictionaries, but since
the
> &gt; code in Lang.js seems to be very tied to OpenLayers.Lang this seems
hard
> &gt; without copying too much code.
> &gt;
> &gt; Thoughts appreciated.
> &gt;
> &gt; Best regards,
> &gt; Bart
> &gt;
> &gt; --
> &gt; Bart van den Eijnden
> &gt; OSGIS, Open Source GIS
> &gt; http://www.osgis.nl
> &gt;
> &gt;
> &gt;
> &gt;
> &gt;
> &gt; _______________________________________________
> &gt; Dev mailing list
> &gt; Dev at openlayers.org
> &gt; http://openlayers.org/mailman/listinfo/dev
> &gt;
> &gt;   
> 
> 






More information about the Dev mailing list