FyreLang is a free, open-source language library for PHP.
Using Composer
composer require fyre/lang
In PHP:
use Fyre\Lang\Lang;
Add Path
Add a language path.
$path
is the path to add.$prepend
is a boolean indicating whether to prepend the file path, and will default to false.
Lang::addPath($path, $prepend);
Clear
Clear all language data.
Lang::clear();
Get
Get a language value.
$key
is the key to lookup.$data
is an array containing data to insert into the language string.
$lang = Lang::get($key, $data);
See the MessageFormatter::formatMessage method for details about message formatting.
Get Default Locale
Get the default locale.
$defaultLocale = Lang::getDefaultLocale();
Get Locale
Get the current locale.
$locale = Lang::getLocale();
Get Paths
Get the paths.
$paths = Lang::getPaths();
Set Default Locale
Set the default locale.
$locale
is the locale.
Lang::setDefaultLocale($locale);
Remove Path
Remove a path.
$path
is the path to remove.
$removed = Lang::removePath($path);
Set Locale
Set the current locale.
$locale
is the locale.
Lang::setLocale($locale);