# OpenLayers.Lang

Internationalization namespace. Contains dictionaries in various languages and methods to set and get the current language.

Summary

OpenLayers.Lang | Internationalization namespace.
Properties |
code | {String} Current language code to use in OpenLayers.
defaultCode | {String} Default language to use when a specific language can’t be found.
Functions |
getCode | Get the current language code.
setCode | Set the language code for string translation.
translate | Looks up a key from a dictionary based on the current language string.
OpenLayers.i18n | Alias for OpenLayers.Lang.translate.

### Properties

### code

{String} Current language code to use in OpenLayers. Use the setCode method to set this value and the getCode method to retrieve it.

### defaultCode

{String} Default language to use when a specific language can’t be found. Default is “en”.

### Functions

### getCode

> getCode: function()

Get the current language code.

#### Returns

{String} The current language code.

### setCode

> setCode: function( | code | )

Set the language code for string translation. This code is used by the OpenLayers.Lang.translate method.

#### Parameters

code | {String} These codes follow the IETF recommendations at http://www.ietf.org/rfc/rfc3066.txt. If no value is set, the browser’s language setting will be tested. If no OpenLayers.Lang dictionary exists for the code, the <OpenLayers.String.defaultLang> will be used.

### translate

> translate: function( | key,
> | context | )

Looks up a key from a dictionary based on the current language string. The value of getCode will be used to determine the appropriate dictionary. Dictionaries are stored in OpenLayers.Lang.

#### Parameters

key | {String} The key for an i18n string value in the dictionary.
context | {Object} Optional context to be used with OpenLayers.String.format.

#### Returns

{String} A internationalized string.

### OpenLayers.i18n

Alias for OpenLayers.Lang.translate. Looks up a key from a dictionary based on the current language string. The value of OpenLayers.Lang.getCode will be used to determine the appropriate dictionary. Dictionaries are stored in OpenLayers.Lang.

#### Parameters

key | {String} The key for an i18n string value in the dictionary.
context | {Object} Optional context to be used with OpenLayers.String.format.

#### Returns

{String} A internationalized string.

> getCode: function()

Get the current language code.

> setCode: function( | code | )

Set the language code for string translation.

> translate: function( | key,
> | context | )

Looks up a key from a dictionary based on the current language string.
Internationalization namespace.

> format: function( | template,
> | context,
> | args | )

Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object.
Close