RE: How to implement multilanguage support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have written several sites which have needed multilanguage support.  The
smallest site made use of javascript to generate text client-side.  That way
all the text gets downloaded in one go and all the effort is concentrated on
the client.  That worked ok for that client but I would not recommend it.

The other way I have used is to have all the translated text in a database.
You have a country table and a text table.  Country has a unique id and the
text table is unique by a compound key of country id and text id.  In your
PHP code whenever you need a literal or some content text you create a new
entry in the text table and generate a new id for it.  That id is used in
the PHP to retrieve the text.  The text retrieval method uses a combination
of the text id and the 'current language' id to retrieve the text.

For example:


	html...
		php...
			print(Text::getLDString(68) ." ");
		...php
	...html

	// Gets a language dependent string from the database.
	// Instantiates the text object identified by the specified
	// id and countryId and returns the string textData associated
	// with it.
	function getLDString($id=0){
		global $session; 

		$currentCountry = $session->getCurrentCountry();
		if (!$id || $id == 0){
			return "Invalid string request, id not specified";
		}
		$text = new Text($id, $currentCountry->getId());
		if (!$text || $text->getTextData() == ""){
			$text = new Text($id, DEFAULT_COUNTRY_ID);
		}
		return $text->getTextData();
	}

Thus, you can generate a listbox from the country table to show the user the
list of currently supported languages.

I also wrote a small suite of pages which allowed the developer and
translator to easily access every piece of text from the text table to make
changes add new languages, etc.  This area is then user/password protected
so that if anything needs adjusting it can be done online.

Hope that helps.

-----Original Message-----
From: Mark Groen [mailto:markgroen@xxxxxxxxx] 
Sent: 21 November 2005 04:53
To: php-objects@xxxxxxxxxxxxxxx
Subject: Re:  How to implement multilanguage support

----- Original Message -----
From: "Andres Santos" <>
To: <php-objects@xxxxxxxxxxxxxxx>
Sent: Sunday, November 20, 2005 8:01 PM
Subject: Re:  How to implement multilanguage support


Mmm... that works. But what i want is the CMS to support multilanguage
input
from the users (editors), so that the frontend content of the website
would
be available in many languages.

This FAQ from Textpattern may help:

http://textpattern.com/faq/139/what-languages-does-textpattern-support

btw, I've used TP on a couple projects, it worked well.

cheers,

        Mark




PHP Data object relational mapping generator - http://www.meta-language.net/

Yahoo! Groups Links



 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux