PHP Class Yasumi\Translations

Inheritance: implements yasumi\TranslationsInterface
Show file Open project: azuyalabs/yasumi Class Usage Examples

Public Properties

Property Type Description
$translations translations array: ['' => ['' => 'translation', ...], ... ]

Public Methods

Method 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.

Protected Methods

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

Method Details

__construct() public method

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

addTranslation() public method

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 method

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

getTranslations() public method

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

isValidLocale() protected method

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

loadTranslations() public method

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

Property Details

$translations public property

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