-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
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
Native (GettextTranslator) translator does not work with php 5.5 #107
Comments
I have php5.5 with native gettext working without problems in Ubuntu, so maybe there's a problem with your configuration. To be sure, can you try to use the php functions instead this library? |
Native PHP gettext not working too. So, this is not your mistake, and here is my server configs:
|
Maybe you don't have the locale installed? |
ps. I tested with this code: $language = 'en';
putenv("LANG=$language");
setlocale(LC_ALL, $language);
$domain = 'messages';
bindtextdomain($domain, "data/locales");
textdomain($domain);
echo gettext("Контакты"); |
Installed locale? What do you mean? |
Native gettext use the locales installed in the operating system. This is why is so hard to use it under some circunstances. If you want to use, for instance the language "es", you have to install the locale in your operating system. Note also that the same locale is called differently in some operating systems (for example "es_ES" instead simply "es"). |
I dont think what problem in installed locales. When i use php 5.4 or 5.3 - all work fine. Hm.. What the sh*t.. |
If you are using the native translator, you must have the locale installed and you must set the
$translator = new \Gettext\GettextTranslator();
$translator->setLanguage('de_DE.UTF-8')->loadDomain(
'messages',
'data/locales'
);
die($translator->gettext('Контакты')); Try! |
Setting locale like 'de_DE.UTF-8' has no effect |
My code working, from PHP 5.3 to PHP 7: $locale = 'es_ES.UTF-8';
defined('LC_MESSAGES') or define('LC_MESSAGES', 5);
putenv('LANG='.$locale);
putenv('LANGUAGE='.$locale);
putenv('LC_MESSAGES='.$locale);
putenv('LC_PAPER='.$locale);
putenv('LC_TIME='.$locale);
putenv('LC_MONETARY='.$locale);
setlocale(LC_MESSAGES, $locale);
setlocale(LC_COLLATE, $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MONETARY, $locale);
$translator = new GettextTranslator();
$translator->setLanguage($locale);
$translator->loadDomain('messages', 'gettext');
bind_textdomain_codeset('messages', 'UTF-8');
$translator->register(); But only works after install system package languages and reboot apache. |
$locale = 'de';
defined('LC_MESSAGES') or define('LC_MESSAGES', 5);
putenv('LANG='.$locale);
putenv('LANGUAGE='.$locale);
putenv('LC_MESSAGES='.$locale);
putenv('LC_PAPER='.$locale);
putenv('LC_TIME='.$locale);
putenv('LC_MONETARY='.$locale);
setlocale(LC_MESSAGES, $locale);
setlocale(LC_COLLATE, $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MONETARY, $locale);
$translator = new \Gettext\GettextTranslator();
$translator->setLanguage($locale)->loadDomain(
'messages',
'data/locales'
);
die($translator->gettext('Контакты')); Works with php 5.4, and does not works with php 5.5 IDK why. |
And |
Yep, i tried. It has no effect too |
Oops, here's the problem. |
Thx for support, guys. There is no way. |
Hi guys.
I have one problem with your project and php ver.
5.5
. When i used5.3
or5.4
- all works fine, but when i updated php to5.5
- native translator (classGettextTranslator
,vendor\gettext\gettext\src\GettextTranslator.php
) stop working for me. If i use phpTranslator
(vendor\gettext\gettext\src\Translator.php
) - all is ok again, but i need exactly in native translator.Test string:
Files structure:
Test code:
First test:
Output:
Kontakte
All is ok. Second test:
Output:
My string is not translated. Test code was not changed.
Gettext installed by composer and source has no any changes by me:
Server software:
Can you fix this or say me how can i do it?
The text was updated successfully, but these errors were encountered: