[OpenLayers-Trac] [OpenLayers] #109: Pull all strings out and into a single js file for localization

OpenLayers trac at openlayers.org
Thu Feb 14 14:55:22 EST 2008


#109: Pull all strings out and into a single js file for localization
----------------------+-----------------------------------------------------
  Reporter:  euzuro   |       Owner:  tschaub    
      Type:  task     |      Status:  assigned   
  Priority:  minor    |   Milestone:  2.6 Release
 Component:  general  |     Version:  2.3        
Resolution:           |    Keywords:             
     State:  Review   |  
----------------------+-----------------------------------------------------
Comment (by tschaub):

 Ok, I've reworked this enough that I'd like another set of eyes on it for
 a review.

 I moved everything relevant to i18n into the OpenLayers.Lang namespace.
 This adds the following to our API:

  * OpenLayers.Lang.defaultCode - Default language code.

  * OpenLayers.Lang.setCode - Used for setting language codes.  With no
 argument, you get the browser default, or if no dictionary exists for
 that, you get OpenLayers.Lang.defaultCode.

  * OpenLayers.Lang.getCode - Used to retrieve the current language code.

  * OpenLayers.Lang.translate - Used to look up a key from the current
 language dictionary and optionally format based on some context.

  * OpenLayers.i18n - Alias for OpenLayers.Lang.translate

 The reason to add the accessor method was to have it run only once per
 language code change.  In the previous patch, the language code selection
 was run once for each translate.  I also like the idea that all this goes
 in the Lang namespace instead of being split between Lang and String.

 I've also cut down the dictionaries so they only contain relevant keys.
 To add to a regional dictionary, we can inherit from the primary.

 I think this is good to go.  Additional review appreciated.  (Tests pass
 in FF/Safari.)

-- 
Ticket URL: <http://trac.openlayers.org/ticket/109#comment:15>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list