PHP Class Yasumi\Translations

Inheritance: implements yasumi\TranslationsInterface
Afficher le fichier Open project: azuyalabs/yasumi Class Usage Examples

Méthodes publiques

Свойство Type Description
$translations translations array: ['' => ['' => 'translation', ...], ... ]

Méthodes publiques

Méthode Description
__construct ( array $availableLocales ) Constructor.
addTranslation ( string $shortName, string $locale, string $translation ) Adds translation for holiday in specific locale.
getTranslation ( string $shortName, string $locale ) : string | null Returns translation for holiday in specific locale.
getTranslations ( string $shortName ) : array Returns all available translations for holiday.
loadTranslations ( string $directoryPath ) Loads translations from directory.

Méthodes protégées

Méthode Description
isValidLocale ( string $locale ) : true Checks whether the given locale is a valid/available locale.

Method Details

__construct() public méthode

Constructor.
public __construct ( array $availableLocales )
$availableLocales array list of all defined locales

addTranslation() public méthode

Adds translation for holiday in specific locale.
public addTranslation ( string $shortName, string $locale, string $translation )
$shortName string holiday short name
$locale string locale
$translation string translation

getTranslation() public méthode

Returns translation for holiday in specific locale.
public getTranslation ( string $shortName, string $locale ) : string | null
$shortName string holiday short name
$locale string locale
Résultat string | null translated holiday name

getTranslations() public méthode

Returns all available translations for holiday.
public getTranslations ( string $shortName ) : array
$shortName string holiday short name
Résultat array holiday name translations ['' => '', ...]

isValidLocale() protected méthode

Checks whether the given locale is a valid/available locale.
protected isValidLocale ( string $locale ) : true
$locale string locale the locale to be validated
Résultat true upon success, otherwise an UnknownLocaleException is thrown

loadTranslations() public méthode

Loads translations from directory.
public loadTranslations ( string $directoryPath )
$directoryPath string directory path for translation files

Property Details

$translations public_oe property

translations array: ['' => ['' => 'translation', ...], ... ]
public $translations