Plex Media Center for OS X Leopard

5.1.3. Locale — Localizaion and geolocation

The Locale module provides location-based services to plug-ins, allowing the developer to leverage the framework’s built-in localization and geolocation features. To make use of the string localization features, a strings file for each language or location should be created in the Contents/Strings directory. See the Bundles section for more information.

This module defines the following functions:

Locale.SetDefaultLocale(loc = "en-us")

Sets the default locale used by a plug-in. The default locale will be used as a fallback when no strings exist for the user’s current locale (provided automatically by Plex).

TODO: Link to ISO standards for language & location

Parameter:loc (str) – The locale to use as the default. This should be a string containing a language (or language and location), e.g. en, en-us or en-gb.
Locale.LocalString(key)

Finds a localized string in the available strings files based on the given key. The framework will attempt to find the best match for the key.

Parameter:key (str) – The key of the string to return
Returns:The localized string represented by the key, or the provided key if no string was found.
Return type:str

Note

A shortcut for this function is available. See Shortcuts for more details.

Locale.Geolocation()

Returns the user’s current geographic location based on their IP address.

TODO: Link to ISO country codes

Returns:A two-character code representing the user’s country.
Return type:str

Note

An active Internet connection is required to obtain the user’s location.

Previous topic

5.1.2. Resource — Bundled resource management

Next topic

5.1.4. Prefs — Manages user preferences