pedro84 Posted October 28, 2006 Share Posted October 28, 2006 Hello!I try to make translate my site with gettext function. I have reade thins manual: [url=http://pl.php.net/manual/pl/function.gettext.php]http://pl.php.net/manual/pl/function.gettext.php[/url]But I have problem. Languages on my main page changes with sessions, like this:[code]<?phpsession_start();require_once("langman.php");if(!SelectLanguage($_SESSION["lang"])) die("Error selecting language!");?>[/code]Everything Works, but don't work in other scripts. So i tried to translate them with gettext.In main file of the script I put:[code]setlocale(LC_ALL, $_SESSION["lang"] );bindtextdomain("news", "./lang");textdomain("news");[/code]Exapmle .MO file:[code]msgid "Football"msgstr "Fussbal"[/code]Path is corect as follow:C:\usr\apache\httpd\html\news\lang\de_DE\LC_MESSAGES.I call this by:[code]echo _("Football");[/code]And don't work.Anyoe know what I'm doing wrong? Link to comment https://forums.phpfreaks.com/topic/25422-gettext-problems/ Share on other sites More sharing options...
toplay Posted October 28, 2006 Share Posted October 28, 2006 Perhaps try calling the following in order (look at the manual on php.net for argument info):putenv("LANG=" . $_SESSION["lang"]);setlocale(LC_ALL, $_SESSION["lang"]);bindtextdomain('domain', 'path');bind_textdomain_codeset('domain', 'your char set');textdomain('domain');echo gettext('Football'); // or can use the shorter version: _('Football');Source translation files should be the .po and the compiled/generated is .mo.Try using something like poedit http://www.poedit.org to create your translations because it will tell you if you have an error (or duplicates), and it will generate the .mo files for you.http://us3.php.net/manual/en/function.gettext.php Link to comment https://forums.phpfreaks.com/topic/25422-gettext-problems/#findComment-116031 Share on other sites More sharing options...
pedro84 Posted October 28, 2006 Author Share Posted October 28, 2006 I have done it, but still doesn't work for me. I have reade this manual several times. Have anyone any suggestions. Link to comment https://forums.phpfreaks.com/topic/25422-gettext-problems/#findComment-116038 Share on other sites More sharing options...
toplay Posted October 28, 2006 Share Posted October 28, 2006 What exactly do you mean by "I have done it..."?Your original code example doesn't even use gettext() but just an echo. Link to comment https://forums.phpfreaks.com/topic/25422-gettext-problems/#findComment-116049 Share on other sites More sharing options...
pedro84 Posted October 28, 2006 Author Share Posted October 28, 2006 My friend said me to try this:mainfile[code]require 'lang/'.$_SESSION['lang'].'.php';[/code]de.php[code]<php$lang['HELO'] = 'NIEMIECKI';?>[/code][code]<?phpecho $lang['HELO'];?>[/code]But it shows me, only thi first letter oh lang, ex. d for de, p for plWhat is wrong here? Link to comment https://forums.phpfreaks.com/topic/25422-gettext-problems/#findComment-116060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.