Jelix 1.6.40

jLocale
in package

static class to get a localized string

Tags
subpackage

core

Table of Contents

$bundles  : array<string|int, array<string|int, jBundle>>
$langToLocale  : array<string|int, mixed>
get()  : string
gets the correct string, for a given language.
getCorrespondingLocale()  : string
says if the given locale or lang code is available in the application
getCurrentCountry()  : string
gets the current country.
getCurrentLang()  : string
gets the current lang
getPreferedLocaleFromRequest()  : string
returns the locale corresponding of one of the accepted language indicated by the browser, and which is available in the application.
langToLocale()  : string
returns the locale corresponding to a lang.
__construct()  : mixed
static class.

Properties

$langToLocale

protected static array<string|int, mixed> $langToLocale = ull

content of the lang_to_locale.ini.php

Methods

get()

gets the correct string, for a given language.

public static get(string $key[, array<string|int, mixed> $args = null ][, string $locale = null ][, string $charset = null ]) : string

if it can't get the correct language, it will try to gets the string from the default language. if both fails, it will raise an exception.

Parameters
$key : string

the key of the localized string

$args : array<string|int, mixed> = null

arguments to apply to the localized string with sprintf

$locale : string = null

the lang code. if null, use the default language

$charset : string = null

the charset code. if null, use the default charset

Tags
throws
Exception
throws
jExceptionSelector
Return values
string

the localized string

getCorrespondingLocale()

says if the given locale or lang code is available in the application

public static getCorrespondingLocale(mixed $l[, bool $strictCorrespondance = false ]) : string
Parameters
$l : mixed
$strictCorrespondance : bool = false

if true don't try to find a locale from an other country

Return values
string

the corresponding locale

getCurrentCountry()

gets the current country.

public static getCurrentCountry() : string
Return values
string

getCurrentLang()

gets the current lang

public static getCurrentLang() : string
Return values
string

getPreferedLocaleFromRequest()

returns the locale corresponding of one of the accepted language indicated by the browser, and which is available in the application.

public static getPreferedLocaleFromRequest() : string
Return values
string

the locale. empty if not found.

langToLocale()

returns the locale corresponding to a lang.

public static langToLocale(string $lang) : string

The file lang_to_locale give corresponding locale, but you can override these association into the langToLocale section of the main configuration

Parameters
$lang : string

a lang code (xx)

Return values
string

the corresponding locale (xx_YY)

__construct()

static class.

private __construct() : mixed

..

Return values
mixed

Search results