12

I need to setup CodeIgniter to be a truly multi language website. I've searched but I can't find a solution.

I've tested this approach but it is not working. (http://codeigniter.com/wiki/Category%3AInternationalization%3A%3AInternationalization_Views_i18n/)

Can someone give me a clue about what setup to use to get a truly multi language environment in CodeIgniter?

Best Regards,

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
André
  • 24,706
  • 43
  • 121
  • 178
  • 2
    **A truly multi language website?** What do you mean exactly? – i.am.michiel May 24 '11 at 14:40
  • Sorry for my bad english. I need to have the URI like this: www.mysite.com/en/controller, www.mysite.com/pt/controller, www.mysite.com/de/controller – André May 24 '11 at 14:41
  • He really means internationalization (i18n). Does this question help at all: http://stackoverflow.com/questions/1328420/the-best-way-to-make-codeigniter-website-multi-language-calling-from-lang-arrays/1328437#1328437 – Justin Ethier May 24 '11 at 14:54
  • @JustinEthier: This uses the session approach with language files. It looks like André wants to use a url segment to determine the language, and load completely different view files instead of just translating small bits here and there. I'm sure that's been answered here too but I'm too lazy to look it up atm. – Wesley Murch May 24 '11 at 18:13

2 Answers2

11

https://github.com/EllisLab/CodeIgniter/wiki/CodeIgniter-2.1-internationalization-i18n

If you implement this, you URLs will contain the language code. You can save your language parts in the language directory. With the function lang();

Loading language files and handling them is explained here: https://www.codeigniter.com/user_guide/libraries/language.html

The helper: https://www.codeigniter.com/user_guide/helpers/language_helper.html

Easiest way is have to some global language files which you auto load. I suggest creating a language file for every controller. So you only load the part you need instead of loading all language files.

Stack Programmer
  • 679
  • 6
  • 18
P.T.
  • 3,130
  • 4
  • 19
  • 24
0

From what I have learned. Building your own libraries and modules to handle them is a key. I haven't had much success with the native support as its a bit tricky sometimes. But basics to it is you have your default site load with the options to choose a language of your choice where within the site you echo out variables instead of static text. Those variables are then stored in what you can call a language pack. Where you have the same variables per language pack but the translated version per pack language. With code igniter it might be a bit more difficult then just appending to your url an identify for any given other language ie: mydomain.com/en/ mydomain.com/it/ mydomain.com/fr/ and then having a language load based off the URL like that however you can use CI's built in session support to store which language should be displayed. And based off of that display the choosen language I know thats not a super dead on answer how to do it, but this is how I would handle it should I ever get a project where I want multi language support.

chris
  • 36,115
  • 52
  • 143
  • 252
  • Don't handle multiple languages using language cookie (session) and detain the sme URL. In SEO means, this would be duplicate content – Hrvoje Golcic May 16 '14 at 13:36