Download the PHP package davidlienhard/i18n without Composer
On this page you can find all versions of the php package davidlienhard/i18n. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidlienhard/i18n
More information about davidlienhard/i18n
Files in davidlienhard/i18n
Package i18n
Short Description 🐘 php library to use for internationalization
License MIT
Homepage https://github.com/davidlienhard/i18n/
Informations about the package i18n
davidlienhard/i18n
🐘 php library to use for internationalization
Setup
You can install through composer
with:
Note: davidlienhard/i18n requires PHP 8.0
How to use
1. Create language files
Create at least one language file. Supported filetypes are json
, yaml
, yml
or ini
.
./lang/en.yml
(English)
./lang/de.yml
(German)
2. Load the class
Use composer autoloader if possible or include the files in the src
folders manually
3. Create the object
4. Set the options
you can either set some options right through the constructor or via the set methods
The following setter methods are available:
setFilePath(string $filePath)
: Sets the path to the language filessetCachePath(string $cachePath)
: Sets the path to the cache directorysetFallbackLang(string $fallbackLang)
: sets a fallback languagesetMergeFallback(bool $mergeFallback)
: whether or not to merge the fallback languagesetPrefix(string $prefix)
: Sets the prefix/name of the class to contain the translationssetForcedLang(string $forcedLang)
: a language that is forced to be usedsetSectionSeparator(string $sectionSeparator)
: the character to use to concatenate sections
5. Initialize the class / create cache-files
Thss will then create the cache file if required and load the new translation data with the given namespace & prefix/class-name.
6. Use the translation data
License
The MIT License (MIT). Please see LICENSE for more information.