Many clients develop their applications with only one language in mind. Recently one of our clients after we had developed two different applications for them decided that the applications needed to be translated into seven different languages. At first the client said, “We’ll just make seven copies of it, and update each one separately.” While this may at first seem the be a quick simple solution, think of the long term affects of this. First, if the application is large, you are going to be wasting much space. Second, and most important, using this approach you are going to be stuck trying to maintain seven different copies of the same application; every update for each each application will have to be made seven times. Not only is this error prone, but it is inefficient.
Our solution? Use a common practice called internationalization (i18n) and localization (l10n). i18n and l10n is text translation (from page content to form labels to error message) and localizing of content ( displaying dates, currency, numbers, etc. in a specific format). For many applications this is not an easy process, and often could require one to go back and rewrite much of the code. However, we use Symfony which makes the task much easier. Symfony allows you to use dictionary files and the database to handle this. Symfony can scan your entire project looking for specific markup(__(“Text here”)) and pull the strings out into a simple XML file which you can enter the translations for. The file looks like the following:
With file all you need to do is to modify the <target /> to <target>My Translated Text</target> When the string “My String To Be Converted” is output in the application it will be converted to “My Translated Text”. You’d save this file for example as messages.es.xml if it was the Spanish translation file.
To read more on internationalization with Symfony visit http://www.symfony-project.org/book/1_2/13-I18n-and-L10n. We use Symfony because of situations like this it allows us to quickly adapt our products to our customer needs.
Always think ahead when developing your applications. Planning for the future work on an application can save you hours of rewriting.