Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mordisacks/i18n
Small but powerful locale library
https://github.com/mordisacks/i18n
Last synced: 4 days ago
JSON representation
Small but powerful locale library
- Host: GitHub
- URL: https://github.com/mordisacks/i18n
- Owner: MordiSacks
- License: mit
- Created: 2016-06-12T13:10:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-11T09:20:22.000Z (over 3 years ago)
- Last Synced: 2024-11-08T17:52:13.416Z (7 days ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# I18n
Small but powerful locale library.# Installation
```
composer require mordisacks/i18n
```# Usage
Set locales directory
```
\MordiSacks\I18n\I18n::$dir = 'Lang';
```Set current locale
```
\MordiSacks\I18n\I18n::$locale = 'he_IL';
```Auto generate mode,
If autoGenerate is set to true,
Any missing domains and/or strings will be auto generated
To use, simply state the following
```
\MordiSacks\I18n\I18n::$autoGenerate = true;
```Translate!
```
echo \MordiSacks\I18n\I18n::translate('Hello World!', 'default');
```
If your text domain is "default", you can leave that parameter out
```
echo \MordiSacks\I18n\I18n::translate('Hello World!');
```
And via helper
```
echo __('Hello World!');
```Variable injection!
Added in version 2.0.0
```
$name = 'Mordi';
echo __('Hello :name', 'default', compact('name'))
// Outputs "Hello Mordi"
```# changelog
## 3.0.0
* Renamed production to autoGenerate