$ composer require germania-kg/i18n
Class DGettextRenderer: This callable now expects returned messages to enclose placeholders with curly braces.
These classes have been used in v1, developers are encouraged to not use them any longer.
Germania\i18n\ServiceProvider
Germania\i18n\AcceptedLanguageStringFactory
<?php
use Germania\i18n\GettextMiddleware;
$locale = "en_GB";
$domains = ["app", "project"];
$path = "./locales";
$middleware = new GettextMiddleware($locale, $domains, $path);
<?php
use Germania\i18n\LanguageNormalizer;
$norm = new LanguageNormalizer;
$norm("de-de"); // "de_DE"
The constructor requires a client and and default language.
<?php
use Germania\i18n\Translator;
$t = new Translator("de", "en");
echo $t("Just a string, nothing to translate");
// "Just a string, nothing to translate"
$var = array(
"de" => "Deutsch: Nur eine String-Variable",
"en" => "English: Just a string variable"
);
echo $t($var);
// "Deutsch: Nur eine String-Variable"
echo $t($var, "en");
// "English: Just a string variable"
Callable wrapper around dgettext for a given domain. Optionally expands at runtime variable placeholders given in second parameter:
<?php
use Germania\i18n\DGettextRenderer;
$domain = "app";
$dgr = new DGettextRenderer($domain);
echo $dgr("MsgId");
// "Some translated {placeholder} messages"
echo $dgr("MsgId", [
"placeholder" => "success"
]);
// "Some translated success messages"
$ git clone https://github.com/GermaniaKG/i18n.git
$ cd i18n
$ composer install
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test
# or
$ vendor/bin/phpunit