We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reproduce
Create /tmp/test.php
/tmp/test.php
<?php _('Hello'); _('Amazing %name%!');
Next run xgettext /tmp/test.php (this creates a file called messages.po)
xgettext /tmp/test.php
messages.po
Change the "Content-Type: text/plain; charset=CHARSET\n" in this file and replace CHARSET with UTF-8 in this case.
"Content-Type: text/plain; charset=CHARSET\n"
UTF-8
Change the "Language: \n" in this file: "Language: uk\n"
"Language: \n"
"Language: uk\n"
Next translate all strings:
msgid "Hello" msgstr "Привіт" msgid "Amazing %name%!" msgstr "Чудовий %name%!"
Save and use the command msgfmt -o messages.mo messages.po which will create a compiled .mo file called messages.mo
msgfmt -o messages.mo messages.po
messages.mo
Create locale dir mkdir -p /tmp/locale/uk_UA.utf8/LC_MESSAGES
mkdir -p /tmp/locale/uk_UA.utf8/LC_MESSAGES
Place this file in this directory /tmp/locale/uk_UA.utf8/LC_MESSAGES/messages.mo
/tmp/locale/uk_UA.utf8/LC_MESSAGES/messages.mo
Create test script /tmp/gettext.php:
/tmp/gettext.php
<?php use Phalcon\Translate\Adapter\Gettext; $translator = new Gettext( [ 'locale' => 'uk_UA.utf8', 'defaultDomain' => 'messages', 'directory' => '/tmp/locale', ] ); echo $translator->query('Hello'), PHP_EOL; echo $translator->t('Amazing %name%!', ['name' => 'Phalcon']), PHP_EOL; echo $translator->_('Hello'), PHP_EOL;
Actual
Hello Amazing Phalcon! Hello
Expected
Привіт Чудовий Phalcon! Привіт
The text was updated successfully, but these errors were encountered:
Are you sure its phalcon problem ? You should check http://php.net/manual/en/function.gettext.php it with php builded functions.
Sorry, something went wrong.
Merge pull request #11312 from sergeyklay/translate/gettext
dadc502
Fixed issue #11311, #11310
Fixed in 2.0.x
2.0.x
No forget to set category
use Phalcon\Translate\Adapter\Gettext; $translator = new Gettext( [ 'locale' => 'uk_UA.utf8', 'defaultDomain' => 'messages', 'directory' => '/tmp/locale', 'category' => LC_MESSAGES ] ); echo $translator->query('Hello'), PHP_EOL; echo $translator->t('Amazing %name%!', ['name' => 'Phalcon']), PHP_EOL; echo $translator->_('Hello'), PHP_EOL;
No branches or pull requests
How to reproduce
Create
/tmp/test.php
Next run
xgettext /tmp/test.php
(this creates a file calledmessages.po
)Change the
"Content-Type: text/plain; charset=CHARSET\n"
in this file and replace CHARSET withUTF-8
in this case.Change the
"Language: \n"
in this file:"Language: uk\n"
Next translate all strings:
Save and use the command
msgfmt -o messages.mo messages.po
which will create a compiled .mo file calledmessages.mo
Create locale dir
mkdir -p /tmp/locale/uk_UA.utf8/LC_MESSAGES
Place this file in this directory
/tmp/locale/uk_UA.utf8/LC_MESSAGES/messages.mo
Create test script
/tmp/gettext.php
:Actual
Expected
The text was updated successfully, but these errors were encountered: