PHP code example of yiisoft / translator-extractor
1. Go to this page and download the library: Download yiisoft/translator-extractor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yiisoft / translator-extractor example snippets
use \Yiisoft\Translator\Message\Php\MessageSource;
return [
Extractor::class => [
'__construct()' => [
[
DynamicReference::to([
'class' => ExtractorCategorySource::class,
'__construct()' => [
'app',
'messageReader' => DynamicReference::to(static fn () => new MessageSource($params['yiisoft/translator-extractor']['messagePath'])),
'messageWriter' => DynamicReference::to(static fn () => new MessageSource($params['yiisoft/translator-extractor']['messagePath'])),
],
]),
],
],
'->translate' // optional, default value for Translation call to look for.
],
];
shell
find src/ -name *.php | xargs xgettext --from-code=utf-8 --language=PHP --no-location --omit-header --sort-output --keyword=translate --output="locales/category.pot"
for d in locales/*/ ; do
for i in locales/*.pot; do
if [ ! -f "$d$(basename "$i" .pot).po" ]; then
touch "$d$(basename "$i" .pot).po"
fi
msgmerge --update --silent --backup=off "$d$(basename "$i" .pot).po" $i
done
done
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.