Localization with Json
lang/ en.json fa.json
All language files return an Associative Array:
{ "hi" : "Welcome to our website", "welcome" : "Welcome to our website dear :name" }
use dvlpr1996\PhpLocalization\Localization; $localization = new Localization([ 'driver' => 'json', 'langDir' => __DIR__ . '/lang/', 'defaultLang' => 'en', 'fallBackLang' => 'fa' ]); //lang method Translate the given message echo $localization->lang($key, $replacement);
for example
echo $localization->lang('welcome', [ ':Name' => 'john' ]); // Welcome to our website dear John
If $replacement parameter is uppercase, lowercase or pascal case, It has an effect on the way the string output is displayed
There was an error while loading. Please reload this page.