Skip to content

FyreLang is a free, open-source language library for PHP.

License

Notifications You must be signed in to change notification settings

elusivecodes/FyreLang

Repository files navigation

FyreLang

FyreLang is a free, open-source language library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/lang

In PHP:

use Fyre\Lang\Lang;

Basic Usage

$lang = new Lang($config);

The default locale will be resolved from the "App.locale" key in the Config.

Autoloading

It is recommended to bind the Lang to the Container as a singleton.

$container->singleton(Lang::class);

Any dependencies will be injected automatically when loading from the Container.

$lang = $container->use(Lang::class);

Methods

Add Path

Add a language path.

  • $path is a string representing 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 a string representing 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();

Remove Path

Remove a path.

  • $path is a string representing the path to remove.
$lang->removePath($path);

Set Default Locale

Set the default locale.

  • $locale is a string representing the locale.
$lang->setDefaultLocale($locale);

Set Locale

Set the current locale.

  • $locale is a string representing the locale.
$lang->setLocale($locale);

About

FyreLang is a free, open-source language library for PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages