PHP and creating a new (spoken) language translation?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chocky
Forum Newbie
Posts: 1
Joined: Thu Jul 01, 2004 4:58 am

PHP and creating a new (spoken) language translation?

Post by chocky »

I'm not terribly optimistic about this, but...

I've just starting fiddling with the setlocale() function for a web site I'm making- and I've made it work fine. My problem is that the site needs to be in English and Welsh- and surprisingly my set up doesn't have the info needed for Welsh!

Now, I could just make a function and custom date function that'd sort this for me, but I'd rather try and do it as "properly" as possible. Is there any way I can create a language file or something to add to the current set up to allow me to set the locale to Welsh?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You can just ste up some language files that hold any words you use in variables like:

Code: Select all

<?php
      $lang['hello'] = "hello";
      $lang['thank you'] = "thank you";
   ?>

Code: Select all

<?php
      $lang['hello'] = "bonjour";
      $lang['thank you'] = "merci";
   ?>
And then at the start of your page check to see what language your using, and then you can replace all the words in your site with the ones in the language file.
Post Reply