Localization with Array
lang/ en/ app.php ... fa/ app.php ...
All language files return an Associative Array:
<?php return [ 'hi' => 'Welcome to our website', 'welcome' => 'Welcome to our website dear :name' // with $replacement param ];
use dvlpr1996\PhpLocalization\Localization; $localization = new Localization([ 'driver' => 'array', 'langDir' => __DIR__ . '/lang/', 'defaultLang' => 'en', 'fallBackLang' => 'fa' ]); //lang method Translate the given message echo $localization->lang($key, $replacement);
for example
echo $localization->lang('app.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.