Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

What is the best practice, when it comes to views' translation in MVC design pattern, in multilingual website:

  1. Always have only one view file and translate its particular strings with a framework translation function.

  2. Always have as many views as website supports, directly translated, one for each language, and let framework internals load particular language-specific view file for language currently selected by user.

Which of these two options should I use (if there isn't any third one) and why?

share|improve this question
    
the people responsible with translations will find it easier to work with a list of strings rather than sifting through the view markup for strings to translate –  devnull Jun 28 at 19:21

1 Answer 1

up vote 6 down vote accepted

The proper choice is using the single view with the strings stored in the appropriate localization framework for the view.

There are two main reasons for this:

  1. It's DRY. There is one view that is used for all the languages. Consider the joys you will have when you need to change the layout on the view if you have one for each language... you've likely got English and then the FIGS set... and possibly CJK too... That's eight copies of the same view. You're going to miss one and you're going to make a mistake in another one. One view.

  2. The industry behind localization is based on taking a file of strings and translating that file. You might have this person in house instead... either way, they aren't programers. The markup for the view itself - be it php, jsp, erb, or a chunk of javascript. You don't want to be sending them your code, and you don't want them making mistakes in translating your variables, styles, and structures (<font color="black">test</font> becomes <fuente colorido="negro">prueba</fuente>). You, the programmer understand what needs to be translated and what does and giving just this to the person doing the translation makes it less likely to introduce errors.

Use the localization framework. It will make it easier for you, it will make it easier for the person doing the translations.

share|improve this answer
    
I don't know, if I can expect better, more professional and straight-to-the-point answer. Thank you. –  trejder Jun 28 at 19:50
3  
@trejder true story, company that we had translate some documentation also translated the xml schema that was in the documentation. The client had difficulty getting it to validate. –  MichaelT Jun 28 at 19:53
    
FYI <fuente colorido="negro"> is fully supported in HTML Cinco, so its not the best example. –  Graham Sep 3 at 16:32
    
@Graham, are you sure about that? plus translation always targets content rather than structure, markup... –  joe Sep 3 at 16:38
    
@Graham I don't see that working on jsfiddle - do you have an example page where that does work? It was an issue for me when I dealt with translations back in '08. Also, it would be trivial to modify it to <span class="something">test</span> and <lapso clase="algo">prueba</lapso> where the class attribute shouldn't get translated... or put an onclick handler in there with the function name getting translated. The demonstration of the issue remains. –  MichaelT Sep 3 at 16:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.