Welcome Guest, Not a member yet? Register   Sign In
questions on multi-language site with MVC
#1

[eluser]brancher[/eluser]
hi guys

in a multi-language site with CMS, where user will input information in all languages, i will have one text field for each language in database. suppose a project with a title: one field for title (native lang), another for title_en (english), an so on... right?

the question is: should the MODEL or the CONTROLLER handle the LANG selection?

the VIEW will always receive $label. should the MODEL retrieve label and label_en, pass then both to the controller and let him handle the selection or should the MODEL do the job, passing only $label with the proper value according to the active language?

thanx!
#2

[eluser]jedd[/eluser]
[quote author="brancher" date="1238034531"]
in a multi-language site with CMS, where user will input information in all languages, i will have one text field for each language in database.
[/quote]

Can you describe this better please? I think you may be designing this sub-optimally.

I haven't done a multi-language site (but lots of knowledgable people here have). My gut feel, though, particularly where your users are entering data (which implies some registration or login process) is that you'd designate a user's language and store that in the session data. Any database call would refer to that data to determine what to do.
#3

[eluser]cahva[/eluser]
I'd like to comment also that its really not the best way design-wise to have fields like that (title,title_en etc.). I would just add additional language field to the table. If you design this way, you could easily add new languages and would'nt have to touch the db schema at all afterwards.

For the model/controller question I had a mixture of Library and Controller. I've used this library and modified it a little for my needs:
http://codeigniter.com/wiki/Language_Selection/

Does what it says and works like a treat.
#4

[eluser]xwero[/eluser]
brancher you have to keep your data retrieval as light as possible so getting all the fields' language entries is a no-no.

The common language flow is as follows

- (one off) detection of the language in the url
- the detected language sets the language item of the config.php file
- use the language item to get the strings for that language from the language files and database




Theme © iAndrew 2016 - Forum software by © MyBB