Jump to content

Problems with changing language files


digimac

Recommended Posts

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");

?>

Link to comment
Share on other sites

  • 8 months later...

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.