Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

multi-language website


ghost's Avatar
0 0

hi, i want ask, what is the best opinion to make multilanguage site, sotre translations in array, or in database? or something else, thanks


ghost's Avatar
0 0

I have done it like so

eng.inc.php

$word_1 = "English word";

otherlang.inc.php

$word_1 = "Other lang word";

main.php

if(isset($_GET['lang']))
{
if($_GET['lang'] == 1)
{
include eng.inc.php;
}
}
echo $word_1;```

That should start u off in the right direction .

Btw this is just an example, it will need security etc.

ghost's Avatar
0 0

2 Zephyr_Pure: yes i know i can use google, but i want to know yours opinion


ghost's Avatar
0 0

I hate them pre-made codes, i always like to write my own.

:D


ghost's Avatar
0 0

mistake25 wrote: 2 Zephyr_Pure: yes i know i can use google, but i want to know yours opinion

Okay… my opinion is that you should use a db with tables for your different content areas and translations for each language, then dynamically populate your pages based upon the language that your visitor chose (and had set through a session variable by your code, most likely).


ghost's Avatar
0 0

I dnt think that a database is needed for this, just either flat file system , or an .inc file should do, but depends on how much content you want to change.


ghost's Avatar
0 0

Coder Disaster wrote: I dnt think that a database is needed for this, just either flat file system , or an .inc file should do, but depends on how much content you want to change.

It's not needed for that, no… nor did I state it was. I gave my suggestion. Is it necessary to have multiple directories and files holding the same content in different languages? No… but, that doesn't make your suggestion any less valid, either.


ghost's Avatar
0 0

I wasnt having a go at you, i assumed you meant use a database to store the translations.

BUt it all depends on how much content he wants to change.


ghost's Avatar
0 0

Coder Disaster wrote: I wasnt having a go at you, i assumed you meant use a database to store the translations.

BUt it all depends on how much content he wants to change.

I did. It depends on how easily expandable he wants it to be, not on how much content he wants to change.

The purpose of a dynamic website driven by database content and static includes is to not have to modify the source every time you want to add a change. For instance, if he decides he wants to add Hebrew to the site at some point, he shouldn't have to manually add it to the included select object listing the languages and to the conditionals in his code that are populating the correct content. Instead, the site should pull all of the available languages from the db when the main page is loaded (to populate the select options), then just run the same queries to pull content based upon the value of a session variable… as compared to the language entry in the db. He could easily add 5, 10, or 100 languages this way.

So, you have a point… and there are different ideal solutions based upon the scope of his idea.


ghost's Avatar
0 0

Yer i agree with that ^^.

If you want i can help you design the DB structure, and create the code.