Open Journal Systems  3.3.0
PKPLocale Class Reference
Inheritance diagram for PKPLocale:
AppLocale

Static Public Member Functions

static _allLocalesCacheMiss ($cache, $id)
 
static & _getAllLocalesCache ()
 
static & _getAllLocalesCacheContent ()
 
static addOctothorpes ($key)
 
static get2LetterFrom3LetterIsoLanguage ($iso3Letter)
 
static get3LetterFrom2LetterIsoLanguage ($iso2Letter)
 
static get3LetterIsoFromLocale ($locale)
 
static & getAllLocales ()
 
static getFilenameComponentMap ($locale)
 
static getIso1FromIso3 ($iso3)
 
static getIso1FromLocale ($locale)
 
static getIso3FromIso1 ($iso1)
 
static getIso3FromLocale ($locale)
 
static getLocale ()
 
static getLocaleDirection ($locale)
 
static & getLocaleFiles ($locale=null)
 
static getLocaleFrom3LetterIso ($iso3Letter)
 
static getLocaleFromIso3 ($iso3)
 
static getLocalePrecedence ()
 
static getLocaleStyleSheet ($locale)
 
static getParameterNames ($source)
 
static getPrimaryLocale ()
 
static getSupportedFormLocales ()
 
static getSupportedLocales ()
 
static getTimeZone ()
 
static initialize ($request)
 
static installLocale ($locale)
 
static isLocaleComplete ($locale)
 
static isLocaleValid ($locale)
 
static isLocaleWithFamilyFirst ($locale)
 
static & loadLocaleList ($filename)
 
static makeComponentMap ($locale)
 
static registerLocaleFile ($locale, $filename, $addToTop=false)
 
static reloadLocale ($locale)
 
static requireComponents ()
 
static translate ($key, $params=array(), $locale=null, $missingKeyHandler=array(__CLASS__, 'addOctothorpes'))
 
static uninstallLocale ($locale)
 

Static Public Attributes

static $request
 

Detailed Description

Provides methods for loading locale data and translating strings identified by unique keys.

Definition at line 73 of file PKPLocale.inc.php.

Member Function Documentation

◆ _allLocalesCacheMiss()

static PKPLocale::_allLocalesCacheMiss (   $cache,
  $id 
)
static

Create a cache file with locale data.

Parameters
$cacheCacheManager
$idthe cache id (not used here, required by the cache manager)

Definition at line 861 of file PKPLocale.inc.php.

References Registry\get(), and loadLocaleList().

◆ _getAllLocalesCache()

static& PKPLocale::_getAllLocalesCache ( )
static

Get the cache object for the current list of all locales.

Returns
FileCache

Definition at line 838 of file PKPLocale.inc.php.

References Registry\get(), and CacheManager\getManager().

Referenced by _getAllLocalesCacheContent().

◆ _getAllLocalesCacheContent()

static& PKPLocale::_getAllLocalesCacheContent ( )
static

◆ addOctothorpes()

static PKPLocale::addOctothorpes (   $key)
static

Add octothorpes to a key name for presentation of the key as missing.

Parameters

Definition at line 243 of file PKPLocale.inc.php.

◆ get2LetterFrom3LetterIsoLanguage()

static PKPLocale::get2LetterFrom3LetterIsoLanguage (   $iso3Letter)
static

Translate the ISO 3-letter language string (ISO639-2b) into a ISO compatible 2-letter string (ISO639-1).

Parameters
$iso3Letterstring
Returns
string the translated string or null if we don't know about the given language.

Definition at line 633 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by PKPLocaleTest\testGet2LetterFrom3LetterIsoLanguage().

◆ get3LetterFrom2LetterIsoLanguage()

static PKPLocale::get3LetterFrom2LetterIsoLanguage (   $iso2Letter)
static

Translate the ISO 2-letter language string (ISO639-1) into a ISO compatible 3-letter string (ISO639-2b).

Parameters
$iso2Letterstring
Returns
string the translated string or null if we don't know about the given language.

Definition at line 614 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by get3LetterIsoFromLocale(), ArticlePubMedXmlFilter\process(), PKPLocaleTest\testGet3LetterFrom2LetterIsoLanguage(), O4DOIXmlFilter\translateLanguageToLocale(), and DataciteXmlFilter\translateLanguageToLocale().

◆ get3LetterIsoFromLocale()

static PKPLocale::get3LetterIsoFromLocale (   $locale)
static

◆ getAllLocales()

◆ getFilenameComponentMap()

static PKPLocale::getFilenameComponentMap (   $locale)
static

Get an associative array of LOCALE_COMPOMENT_... => filename

Parameters
$localestring
Returns
array

Definition at line 361 of file PKPLocale.inc.php.

◆ getIso1FromIso3()

static PKPLocale::getIso1FromIso3 (   $iso3)
static

Translate the ISO639-3 into ISO639-1.

Parameters
$iso3string
Returns
string the translated string or null if we don't know about the given language.

Definition at line 732 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

◆ getIso1FromLocale()

static PKPLocale::getIso1FromLocale (   $locale)
static

Translate the PKP locale identifier into an ISO639-1 compatible 2-letter string.

Parameters
$localestring
Returns
string

Definition at line 762 of file PKPLocale.inc.php.

Referenced by ArticleCrossrefXmlFilter\createJournalArticleNode(), HelpHandler\index(), and DataciteXmlFilter\process().

◆ getIso3FromIso1()

static PKPLocale::getIso3FromIso1 (   $iso1)
static

Translate the ISO 2-letter language string (ISO639-1) into ISO639-3.

Parameters
$iso1string
Returns
string the translated string or null if we don't know about the given language.

Definition at line 714 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by getIso3FromLocale().

◆ getIso3FromLocale()

static PKPLocale::getIso3FromLocale (   $locale)
static

Translate the PKP locale identifier into an ISO639-3 compatible 3-letter string.

Parameters
$localestring
Returns
string

Definition at line 750 of file PKPLocale.inc.php.

References getIso3FromIso1().

Referenced by Dc11SchemaArticleAdapter\extractMetadataFromDataObject().

◆ getLocale()

static PKPLocale::getLocale ( )
static

Return the key name of the user's currently selected locale (default is "en_US" for U.S. English).

Returns
string

Reimplemented in AppLocale.

Definition at line 119 of file PKPLocale.inc.php.

References SessionManager\getManager(), AppLocale\getSupportedLocales(), and isLocaleValid().

◆ getLocaleDirection()

static PKPLocale::getLocaleDirection (   $locale)
static

Get the reading direction for a particular locale.

A locale can specify a reading direction with the direction attribute. If no direction is specified, defaults to ltr (left-to-right). The only other value that is expected is rtl. This value is used in HTML and CSS markup to present a right-to-left layout.

Parameters
$localestring
Returns
string

Definition at line 465 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by BootstrapThreeThemePlugin\init(), HealthSciencesThemePlugin\init(), and PKPTemplateManager\initialize().

◆ getLocaleFiles()

static& PKPLocale::getLocaleFiles (   $locale = null)
static

Get a list of locale files currently registered, either in all locales (in an array for each locale), or for a specific locale.

Parameters
$localestring Locale identifier (optional)

Definition at line 229 of file PKPLocale.inc.php.

References Registry\get().

Referenced by registerLocaleFile(), and translate().

◆ getLocaleFrom3LetterIso()

static PKPLocale::getLocaleFrom3LetterIso (   $iso3Letter)
static

Translate an ISO639-2b compatible 3-letter string into the PKP locale identifier.

This can be ambiguous if several locales are defined for the same language. In this case we'll use the primary locale to disambiguate.

If that still doesn't determine a unique locale then we'll choose the first locale found.

Parameters
$iso3letterstring
Returns
string

Definition at line 671 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent(), AppLocale\getPrimaryLocale(), and AppLocale\getSupportedLocales().

Referenced by PKPLocaleTest\testGetLocaleFrom3LetterIso(), O4DOIXmlFilter\translateLanguageToLocale(), and DataciteXmlFilter\translateLanguageToLocale().

◆ getLocaleFromIso3()

static PKPLocale::getLocaleFromIso3 (   $iso3)
static

Translate an ISO639-3 compatible 3-letter string into the PKP locale identifier.

This can be ambiguous if several locales are defined for the same language. In this case we'll use the primary locale to disambiguate.

If that still doesn't determine a unique locale then we'll choose the first locale found.

Parameters
$iso3string
Returns
string

Definition at line 781 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent(), AppLocale\getPrimaryLocale(), and AppLocale\getSupportedLocales().

◆ getLocalePrecedence()

static PKPLocale::getLocalePrecedence ( )
static

Get the stack of "important" locales, most important first.

Returns
array

Reimplemented in AppLocale.

Definition at line 182 of file PKPLocale.inc.php.

References AppLocale\getLocale().

◆ getLocaleStyleSheet()

static PKPLocale::getLocaleStyleSheet (   $locale)
static

Get the stylesheet filename for a particular locale.

Parameters
$localestring
Returns
string or null if none configured.

Definition at line 446 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by PKPTemplateManager\setupBackendPage(), and PKPLocaleTest\testGetLocaleStylesheet().

◆ getParameterNames()

static PKPLocale::getParameterNames (   $source)
static

Given a locale string, get the list of parameter references of the form {$myParameterName}.

Parameters
$sourcestring
Returns
array

Definition at line 599 of file PKPLocale.inc.php.

References PKPString\regexp_match_all().

Referenced by LocaleFile\testLocale().

◆ getPrimaryLocale()

static PKPLocale::getPrimaryLocale ( )
static

Retrieve the primary locale of the current context.

Returns
string

Reimplemented in AppLocale.

Definition at line 200 of file PKPLocale.inc.php.

References isLocaleValid().

Referenced by BrowseBySectionPlugin\executeSectionFormFields().

◆ getSupportedFormLocales()

static PKPLocale::getSupportedFormLocales ( )
static

Get all supported form locales for the current context.

Returns
array

Reimplemented in AppLocale.

Definition at line 99 of file PKPLocale.inc.php.

References getAllLocales().

◆ getSupportedLocales()

static PKPLocale::getSupportedLocales ( )
static

Get all supported UI locales for the current context.

Returns
array

Reimplemented in AppLocale.

Definition at line 80 of file PKPLocale.inc.php.

References getAllLocales().

◆ getTimeZone()

static PKPLocale::getTimeZone ( )
static

Get the sites time zone.

Returns
string Time zone

Definition at line 880 of file PKPLocale.inc.php.

References DAORegistry\getDAO(), and Config\getVar().

Referenced by initialize().

◆ initialize()

static PKPLocale::initialize (   $request)
static

Initialize the locale system.

Parameters
$requestPKPRequest

Reimplemented in AppLocale.

Definition at line 284 of file PKPLocale.inc.php.

References $request, DBConnection\getInstance(), AppLocale\getLocale(), getTimeZone(), Config\getVar(), and AppLocale\registerLocaleFile().

◆ installLocale()

static PKPLocale::installLocale (   $locale)
static

◆ isLocaleComplete()

static PKPLocale::isLocaleComplete (   $locale)
static

Determine whether or not a locale is marked incomplete.

Parameters
$localexx_XX symbolic name of locale to check
Returns
boolean

Definition at line 478 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

Referenced by InstallForm\__construct(), AdminLanguageGridHandler\loadData(), and PKPLocaleTest\testIsLocaleComplete().

◆ isLocaleValid()

◆ isLocaleWithFamilyFirst()

static PKPLocale::isLocaleWithFamilyFirst (   $locale)
static

Determine whether or not a locale uses family name first.

Parameters
$localexx_XX symbolic name of locale to check
Returns
boolean

Definition at line 492 of file PKPLocale.inc.php.

References _getAllLocalesCacheContent().

◆ loadLocaleList()

static& PKPLocale::loadLocaleList (   $filename)
static

Load a locale list from a file.

Parameters
$filenamestring
Returns
array

Definition at line 518 of file PKPLocale.inc.php.

Referenced by _allLocalesCacheMiss().

◆ makeComponentMap()

static PKPLocale::makeComponentMap (   $locale)
static

Build an associative array of LOCALE_COMPOMENT_... => filename (use getFilenameComponentMap instead)

Parameters
$localestring
Returns
array

Reimplemented in AppLocale.

Definition at line 337 of file PKPLocale.inc.php.

◆ registerLocaleFile()

static PKPLocale::registerLocaleFile (   $locale,
  $filename,
  $addToTop = false 
)
static

Register a locale file against the current list.

Parameters
$localestring Locale key
$filenamestring Filename to new locale XML file
$addToTopboolean Whether to add to the top of the list (true) or the bottom (false). Allows overriding.

Reimplemented in AppLocale.

Definition at line 423 of file PKPLocale.inc.php.

References HookRegistry\call(), and getLocaleFiles().

◆ reloadLocale()

static PKPLocale::reloadLocale (   $locale)
static

Reload locale-specific data.

Parameters
$localestring

Definition at line 588 of file PKPLocale.inc.php.

References installLocale(), and uninstallLocale().

Referenced by PKP\Services\PKPContextService\restoreLocaleDefaults().

◆ requireComponents()

static PKPLocale::requireComponents ( )
static

Load a set of locale components. Parameters of mixed length may be supplied, each a LOCALE_COMPONENT_... constant. An optional final parameter may be supplied to specify the locale (e.g. 'en_US').

Reimplemented in AppLocale.

Definition at line 374 of file PKPLocale.inc.php.

References fatalError().

Referenced by TextureArticleGalleyForm\__construct(), AuthorDepositForm\__construct(), MarkupHandler\_conversion(), MarkupHandler\batch(), TextureHandler\editor(), PKPApplication\getCCLicenseBadge(), MarkupPlugin\manage(), MarkupHandler\profile(), MarkupSettingsTabHandler\settings(), SwordSettingsTabHandler\swordSettings(), and MarkupHandler\triggerConversion().

◆ translate()

static PKPLocale::translate (   $key,
  $params = array(),
  $locale = null,
  $missingKeyHandler = array(__CLASS__, 'addOctothorpes') 
)
static

Translate a string using the selected locale. Substitution works by replacing tokens like "{$foo}" with the value of the parameter named "foo" (if supplied).

Parameters
$keystring
$paramsarray named substitution parameters
$localestring the locale to use
$missingKeyHandlerfunction Callback to be invoked when a key cannot be found.
Returns
string

Reimplemented in AppLocale.

Definition at line 257 of file PKPLocale.inc.php.

References HookRegistry\call(), Registry\get(), AppLocale\getLocale(), and getLocaleFiles().

Referenced by Issue\getIssueIdentification().

◆ uninstallLocale()

static PKPLocale::uninstallLocale (   $locale)
static

Uninstall support for an existing locale.

Parameters
$localestring

Definition at line 577 of file PKPLocale.inc.php.

References DAORegistry\getDAO().

Referenced by reloadLocale(), and AdminLanguageGridHandler\uninstallLocale().

Field Documentation

◆ $request

PKPLocale::$request
static

Definition at line 74 of file PKPLocale.inc.php.

Referenced by initialize().


The documentation for this class was generated from the following file: