Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you transform a pre-existing web app into a multilingual one?

Tags:

I am going to work on a project where a fairly large web app needs to tweaked to handle several languages. The thing runs with a hand crafted PHP code but it's pretty clean.

I was wondering what would be the best way to do that?

  1. Making something on my own, trying to fit the actual architecture.

  2. Rewriting a good part of it using a framework (e.g., Symfony) that will manage i18n for me?

For option 1, where should I store the i18n data? *.po, xliff, pure DB?

I thought about an alternative: using Symfony only for the translation, but setting the controller to load the website as it already is. Quick, but dirty. On the other hand, it allows us to make the next modification, moving slowly to full Symfony: this web site is really a good candidate for that.

But maybe there are some standalone translation engines that would do the job better than an entire web framework. It's a bit like using a bazooka to kill a fly...

like image 352
e-satis Avatar asked Oct 01 '08 09:10

e-satis


People also ask

What is multilingual app?

Multilingual Mobile Applications As depicted by the name, multilingual mobile apps are the applications that work in more than one language. The content that is driven by the right mobile app localization strategy allows the businesses to reach more markets and deliver a personalized experience to the customers.


2 Answers

Work with languages files.

  1. Replace each text string by a variable
  2. Create one language file per language and in it define each variable with their corresponding text. (french.inc, dutch.inc ...)
  3. Include the right file in each page.

That's for small sites.

If getting bigger, replace the files by a DB. :)

like image 56
Veynom Avatar answered Sep 18 '22 07:09

Veynom


There are a number of ways of tackling this. None of them "the best way" and all of them with problems in the short term or the long term. The very first thing to say is that multi lingual sites are not easy, translators and lovely people but hard to work with and most programmers see the problem as a technical one only. There is also another dimension, outside the scope of this answer, as to whether you are translating or localising. This involves looking at the target audiences cultural mores and then tailoring language, style, layout, colour, typeface etc., to that culture. Finally do not use MT, Machine Translation, for anything serious or if it needs to be accurate and when acquiring translators ensure that they are translating from a foreign language into their native language which means that they understand all the nuances of the target language.

Right. Solutions. On the basis that you do not want to rewrite the site then simply clone the site you have and translate the copies to the target language. Assuming the code base is stable you can use a VCS to manage any code changes. You can tweak individual parts of the site to fit the target language, for example French text is on average 30% larger than the equivalent English text so using one site to deliver this means you may (will) have formatting problems and need to swap a different css file in and out depending on the language. It might seem a clunky way to do it but then how long are the sites going to exist? The management overhead of doing it this way may well be less than other options.

Second way without rebuilding. Replace all content in the current site with tags and then put the different language in file or db tables, sniff the users desired language (do you have registered users who can make a preference or do you want to get the browser language tag, or is it going to be URL dot-com dot-fr, dot-de that make the choice) and then replace the tags with the target language. Then you need to address the sizing issues and the image issues separately. This solution is in effect when frameworks like Symfony and Zend do to implement l10n.

Then you could rebuild with a framework or with gettext and possibly have a cleaner solution but remember frameworks were designed to solve other problems, not translation and the translation component has come into the framework as partial solution not the full one.

The big problem with all the solutions is ongoing maintenance. Because not only do you have a code base but also multiple language bases to maintain. Unless you all in one solution is really clever and effective then to ongoing task will be difficult.

like image 30
PurplePilot Avatar answered Sep 21 '22 07:09

PurplePilot