Skip to content

LanguageRepository

Manages languages based on JSON definitions.

Properties

defaultLocale

The default locale.

protected string $defaultLocale

fallbackLocale

The fallback locale.

protected string $fallbackLocale

definitionPath

The path where per-locale definitions are stored.

protected string $definitionPath

definitions

Per-locale language definitions.

protected array $definitions

availableLocales

The available locales.

protected array $availableLocales

Methods

__construct

Creates a LanguageRepository instance.

public __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', string $definitionPath = null): mixed

Parameters:

Parameter Type Description
$defaultLocale string The default locale. Defaults to 'en'.
$fallbackLocale string The fallback locale. Defaults to 'en'.
$definitionPath string The path to the currency definitions.
Defaults to 'resources/language'.

get

Gets a language matching the provided language code.

public get(mixed $languageCode, mixed $locale = null): \CommerceGuys\Intl\Language\Language

Parameters:

Parameter Type Description
$languageCode mixed The language code.
$locale mixed The locale (i.e. fr-FR).

getAll

Gets all languages.

public getAll(mixed $locale = null): \CommerceGuys\Intl\Language\Language[]

Parameters:

Parameter Type Description
$locale mixed The locale (i.e. fr-FR).

Return Value:

An array of languages, keyed by language code.


getList

Gets a list of languages.

public getList(mixed $locale = null): array

Parameters:

Parameter Type Description
$locale mixed The locale (i.e. fr-FR).

Return Value:

An array of language names, keyed by language code.


loadDefinitions

Loads the language definitions for the provided locale.

protected loadDefinitions(string $locale): array

Parameters:

Parameter Type Description
$locale string The desired locale.


Automatically generated on 2025-03-18