Welcome Guest, Not a member yet? Register   Sign In
[Solved] Implementing localization
#1

[eluser]Queops[/eluser]
Hello!

I'm currently looking for a way to include various languages on my website.

Anyone here ever implemented such thing? I'm looking for something simple, since the website is quite simple.

Any kind of resources would be much appreciated!

I hope I posted this on the right place Smile
#2

[eluser]Walter Coots[/eluser]
That's pretty vague. Without having more info, some things to think about:

First, if you're showing text in images or SWF files, you'll have to address that by either generating them on the fly with the appropriate language, or being prepared to retrieve and display multiple versions from the server.

If your content is going to be stored in a database, my guess the best way to do it would be to create one table for languages, and one for metadata. So you have a table called "blog_metadata" with the columns "ID", "langRow", and "date". Then you have a table called "blog_language" with two columns for each language, e.g. "title_english", "entry_english", "title_deustch", "entry_deustch", "title_espanol", "entry_espanol" and so forth. The other way to do it would be to store the language columns along with the metadata, which might be easier to manage. I suppose you could also use multiple tables for each language, or even multiple databases.

Probably the simplest way to do this (with no database) is to just have a switch statement that shows different languages depending on what the user has selected.

Code:
switch($lang)
{
    case 'eng':
        echo("Hello");
        break;
    case 'jap';
        echo("Konnichiwa");
        break;
    case 'tex':
        echo('Howdy');
        break;
    case 'esp':
        echo('Buenos Dias');
        break;
    case 'deu':
        echo('Tag');
        break;
}
#3

[eluser]samwilliamh[/eluser]
If you're only going to be having static content in different languages (such as navigation items maybe) you could take advantage of CodeIgniter's Language class and just load the correct language files depending upon a cookie or something.
#4

[eluser]Queops[/eluser]
Probably should have gave couple more indications. Data isn't stored in a database.
I was hoping I could have something on the view file like {HEADER_TEXT} and that being automatically parsed into the header text on a language file, depending on which language the user choose.

@Sam: wow, that actually seems to do the trick, didn't notice there was such class. Thanks for the heads up!
#5

[eluser]Walter Coots[/eluser]
Maybe check into this:

http://maestric.com/doc/php/codeigniter_i18n




Theme © iAndrew 2016 - Forum software by © MyBB