dev-master
9999999-dev https://github.com/SebRogala/xsv-translateZend Expressive Translation Module
BSD-3-Clause
The Requires
3.0.0
3.0.0.0 https://github.com/SebRogala/xsv-translateZend Expressive Translation Module
BSD-3-Clause
The Requires
Wallogit.com
2017 © Pedro Peláez
Zend Expressive Translation Module
Module made for database oriented resource translating with usage of Doctrine2. However it is quite simple to expand Translator with own kind of Adapter., (*1)
composer require sebrogala/xsv-translate^3.0 cp vendor/sebrogala/xsv-translate/data/xsv-translate-config.global.php.dist config/autoload/xsv-translate-config.global.php
config/config.php adding Xsv\Translate\ConfigProvider::class,
config/pipeline.php before DispatchMiddleware:/* ... */ $app->pipe(\Xsv\Translate\App\Middleware\TranslatorConfigMiddleware::class); $app->pipe(DispatchMiddleware::class); /* ... */
vendor/bin/doctrine orm:schema-tool:update --force
X-Preferable-Locale locale_CODE
//adding translation interface public static function addTranslation($resourceName, $resourceId, Locale $locale, $content)
use Xsv\Translate\Translator\Translator;
/*
...
*/
Translator::addTranslation("resource.name", "id", new Locale("pl_PL"), "TranslationToPolish");
Where:
- "resource.name" is self defined, can be "user.username" - it's about single field.
- "id" is unique id of row (currently it's based on uuid)
#### Translating resource
```php
//translating interface
public static function translate(string $resourceName, string $resourceId, $defaultTranslationContent = "")
```php
use Xsv\Translate\Translator\Translator;
/*
...
*/
return new JsonResponse(
[
"userName" => Translator::translate("user.name", $user->getId(), $user->getUserName())
]
);
Zend Expressive Translation Module
BSD-3-Clause
Zend Expressive Translation Module
BSD-3-Clause