Welcome Guest, Not a member yet? Register   Sign In
Managing multilanguage website with CI
#1

[eluser]WebMada[/eluser]
Hello!

Is there an advised way to manage that in CI
For me, I do like the following:
Code:
switch ($Language) {
        case ("FR") : {
            $Titre = "Bienvenue à Madagascar!";
            $Texte = "Notre mission consiste à rendre le climat des affaires attractif et propice aux investissements.";
            $Invest = "Investir à Madagascar";
            break;
        }
        case ("EN") : {
            $Titre = "Welcome to Madagascar!";
            $Texte = "We aim to make the investment climate attractive<br /> to private companies and favorable to their success";
            $Invest = "Invest in Mada";
            break;
        }
    }

In each start of all views

It's so long and it will be harder when we add more languages

I just remark that other MVC frameworks like JELIX have special classes to manage internationalization (multilanguage)
#2

[eluser]Kamarg[/eluser]
CodeIgniter has a core library for multi-language support. Check the documentation.
#3

[eluser]WebMada[/eluser]
ok, CI has it like in Jelix! Thanx for the link
So, do u advise me to use that now?

I just remark that for my DB datas, i use 2 fields as: Title_en, Title_fr, Content_en, Content_fr !!! The problem is if we will support more languages!
#4

[eluser]Kamarg[/eluser]
Personally I've found the CI library works wonderfully and would recommend you go that route. If you have many languages, it can be tedious to update your files but it would be just as bad with a database.
#5

[eluser]Miroslav Vitanov[/eluser]
[quote author="WebMada" date="1268919270"]ok, CI has it like in Jelix! Thanx for the link
So, do u advise me to use that now?

I just remark that for my DB datas, i use 2 fields as: Title_en, Title_fr, Content_en, Content_fr !!! The problem is if we will support more languages![/quote]

I personally would advise you to split the logic. Create one table which would hold the diffrent laguages for example 'language' with the following structure - lang_id, lang_name, and the if you have news in the news table simply put a field lang_id and depending on the loaded language you select the content written in it.

I hope you got the idea :d




Theme © iAndrew 2016 - Forum software by © MyBB