# Yahoo! UI Library

### yui 3.1.1

Yahoo! UI Library > yui > Intl
Search:
Filters Show Private Show Protected Show Deprecated

## `static` Class Intl - uses EventTarget

The Intl utility provides a central location for managing sets of localized resources (strings and formatting patterns).

### Methods

#### _mod

`private Object _mod ( module )`
Private method to retrieve the language hash for a given module.

Parameters:
  `module <String>` The name of the module

Returns: `Object`
  The hash of localized resources for the module, keyed by BCP language tag

#### add

`void add ( module , lang , strings )`
Register a hash of localized resources for the given module and language

Parameters:
  `module <String>` The module name.
  `lang <String>` The BCP 47 language tag.
  `strings <Object>` The hash of localized values, keyed by the string name.

#### get

`get ( module , key , lang )`
Gets the module's localized resources for the currently active language (as provided by the getLang method).

Optionally, the localized resources for alternate languages which have been added to Intl (see the add method) can be retrieved by providing the BCP 47 language tag as the lang parameter.

Parameters:
  `module <String>` The module name.
  `key <String>` Optional. A single resource key. If not provided, returns a copy (shallow clone) of all resources.
  `lang <String>` Optional. The BCP 47 language tag. If not provided, the module's currently active language is used.

Returns: ``
  String | Object A copy of the module's localized resources, or a single value if key is provided.

#### getAvailableLangs

`Array getAvailableLangs ( module )`
Gets the list of languages for which localized resources are available for a given module, based on the module meta-data (part of loader). If loader is not on the page, returns an empty array.

Parameters:
  `module <String>` The name of the module

Returns: `Array`
  The array of languages available.

#### getLang

`String getLang ( module )`
Get the currently active language for the given module.

Parameters:
  `module <String>` The module name.

Returns: `String`
  The BCP 47 language tag.

#### lookupBestLang

`String lookupBestLang ( preferredLanguages , availableLanguages )`
Returns the language among those available that best matches the preferred language list, using the Lookup algorithm of BCP 47. If none of the available languages meets the user's preferences, then "" is returned. Extended language ranges are not supported.

Parameters:
  `preferredLanguages <String[] | String>` The list of preferred languages in descending preference order, represented as BCP 47 language tags. A string array or a comma-separated list.
  `availableLanguages <String[]>` The list of languages that the application supports, represented as BCP 47 language tags.

Returns: `String`
  The available language that best matches the preferred language list, or "".

#### setLang

`setLang ( module , lang )`
Sets the active language for the given module. Returns false on failure, which would happen if the language had not been registered through the add() method.

Parameters:
  `module <String>` The module name.
  `lang <String>` The BCP 47 language tag.

Returns: ``
  boolean true if successful, false if not.

#### Methods inherited from EventTarget:

`_getType, _monitor, _parseType, addTarget, after, before, bubble, detach, detachAll, fire, getEvent, getTargets, on, once, publish, removeTarget, subscribe, unsubscribe, unsubscribeAll`

### Events

#### intl:langChange

`intl:langChange ( e )`
Notification event to indicate when the lang for a module has changed. There is no default behavior associated with this event, so the on and after moments are equivalent.

Parameters:
  `e <EventFacade>` The event facade

  The event facade contains:

  module
    The name of the module for which the language changed
  newVal
    The new language tag
  prevVal
    The current language tag

Copyright © 2010 Yahoo! Inc. All rights reserved.