:: PSD Help Line :: » Make your Website Go Beyond Boundaries with Multi-Language Support
UXDE dot Net Wordpress Themes

Make your Website Go Beyond Boundaries with Multi-Language Support

in PHP / No Comments

If you wish to take your business global the best way is to attract more buyers is by conversing with them in their native language. Designing a multilingual site fits the bill perfectly. Translating simple with a few static pages will not give you sleepless nights, but translating a little complicated PHP application might do, as it requires extra bit of coding to get the desired result.

With this article we’ll look at the various designing and developing aspects that require attention while translating the website to take it international.

Static Content

Well every site has hard coded text like notification messages, or text strings in template files that are being handled in PHP script. This content can easily be translated to desired language; you just need to translate each string individually.

Now, you must be wondering translating every string is a daunting task. Well there is an easy work around which is provided by Gettext- a software solution capable of handling translations in various applications programmed using different languages. If you’re using PHP, you can get this as an extension.

Gettext allows easy separation of the source code and app translation, thus, enabling the person doing translation to work independently without worrying about the source code. After the translation work is complete, it’s assembled in a separate file to be read by PHP script. When the user views the website in his/her country, the application matches the source text string with the translations and users gets the translated page in the selected language.

As a developer you just need to convert the plain text strings in the PHP application into string type that are readable by Gettext. The text needs to be wrapped into the Gettext() function, which is accessed using “_()”. You have now specified the text string to be translated by Gettext.

Additionally, if you’re making your PHP application using a framework, check if it already has tools for doing the translations.

Content Submitted by User

If you wish to include the feature of user comments and reviews on a post, then you need to include translation for such contents as well.

The foremost step towards this translation is, identifying the language of the content entered by the user. Either you can assume the language to be the same as what user has set for the site, or you can make use of an external API like Google Translate API, to verify the language of the content.

Now, you are sure about the language of the text. It’s time to convert it into all the languages your website supports. Doing this manually will take a toll on anyone, so it’s better to introduce an external API that will do the needful with the machine translation of the content. Moreover, there are various translation API’s available on the net to help you with it.

You might not want to do all this and want to keep the comments in the language it is. It’s your personal choice, but I would recommend that you do translate because it will engage more user’s into discussion.

Converting Resources

Your website might not be all about text content which needs to be translated, there might be few resources being shared on the website as well. These resources can be images, attachments, videos, PDF files. One way of doing the translation of these resources is by keeping these files in a directory reflecting the languages of the site. For instance, the files in English can be stored under the “en” directory, while French files can be stored in “fn” and so on. After doing this, write a helper method to get the necessary file in the language as set by the user. If the file isn’t available in the specific language, then you can display the default version of the resource.

Database Content

Sometimes complex applications make use of database to store information. If the site is single language based, then single version of the data is saved which gets fetched and displayed when required. But, developing a multi-language support website requires working on database as well.

Often, a language code to identify language-specific resources can be used. This simplifies fetching these data in the language set by the user. Your work as a developer increases as you even need to change the database structure.

In such situations frameworks come to the rescue with their offering “behaviors”- a module offering extra functionality to models. Behavior takes responsibility for handling translation of a specified model. A translation behavior is attached to a model, and the framework reads & writes data in different languages using the database structure that handles multiple language support.

Take CakePHP framework that offers Translate behavior, as an example. This translation behavior is attached to the models, but it requires you to specify which model fields are to be translated. If you have an ‘article’ table with two such fields: ‘title’ and ‘text’.


In order to translate the data of these fields, you need to move them to a translation table. Each row in this translation table is identified by the language, model and field name referring to the base table.

Attaching the translate behavior enables you to call model methods in the same manner as before, with framework linking the main table with translation table.

At the End

Launching a site that offer multiple language support isn’t that easy, you need to handle translation of various types of content in varied manner. So if you’re thinking of going international with your website, ensure you have covered all these points before beginning.

Yup, consider pen a silent weapon to bring out all one wishes to come by. So as a writer, it comes common to me accelerate the tiff in making known to all with current and existing subjects. Thus to comprehend all about web designing, developing and more, follow my blogs/posts on psdhelpline.com.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>