digimac Posted March 15, 2007 Share Posted March 15, 2007 Hi guys and gals, Be gentle with me.......newbie to this forum anyway. At the moment I'm working on a group project for university. I have been given the task of figuring out internationalization for our web application. So far I have made progress but am totally stuck with creating a menu that allows the user to change the language. I have already created some trial .mo files using the gettext function for english, spanish, french and german. Example code ive done for testing is below: This code works fine if i manually change the $language = 'de_DE'; to en_GB, es_ES, or fr_FR in the PHP file. However im completely stuck with how to implement this into a pull down xhtml menu, allowing the user to change to a different language from the browser. I can create the menu no problem and have tired switch statements using the form values etc but cannot get anything to work. Any help would be very much appreciated. Sorry about the long first post. Cheers Brian <? // Set the language as 'de_DE' $language = 'de_DE'; putenv("LANG=$language"); setlocale(LC_ALL, $language); // Set the text domain as 'messages' $domain = 'messages'; bindtextdomain("$domain", "./locale"); textdomain("$domain"); // The .mo file searched is: // ./locale/de_DE/LC_MESSAGES/messages.mo echo gettext("Monday"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/42904-problems-with-changing-language-files/ Share on other sites More sharing options...
vspravin Posted November 16, 2007 Share Posted November 16, 2007 Hello Brian, well iam also working on internationalization...but having some problems with using the gettext utility. could u guide how u created the .mo files i'll enumerate the steps that i have used to create the translation files. used the command line utility: xgettext to create a .po file.This file(messages.po) contains the original string with no corresponding translated string then i replaced the default value of charset to 'UTF-8' and renamed this .po file to .pot file following the instructions in the gettext utilities manual used the msginit command line utility to create the lang.po file, but for some reason the corresponding translated string still does not appear in the target language and finally used the command line utility: msgmerge to create .po file merged from lang.po and messages.pot file please help me as iam stuck on this from yesterday... thanks.... regards, Pravin. Quote Link to comment https://forums.phpfreaks.com/topic/42904-problems-with-changing-language-files/#findComment-392783 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.