When building a website, you may think it only makes sense to initially focus on your local market. However, it’s wise to think globally from the beginning as it is time consuming to localize your website later.
The decision to implement localization or not is tied to the nature of your website and products/services and if it’s important to work with other languages and users from different locales. Many CMS’s are internationalization (i18n) ready. In this blog, I will discuss the general translation processes that are platform/framework independent in PHP.
Variables Related to PHP and Design
It’s important to address the variables listed below related to PHP and general design:
Consider the list of target languages (bilingual, predefined set of languages or heterogeneous). Having that set, you can use the GET method to detect the language. Setting cookies and/or IP geolocation in case of query string absence. Another way to detect the language is URL rewrite.
How is your content saved? Is it dynamic (articles and news) and/or static (about us)? You might end up using two methods to handle content. First, is DB tables where you can give column lang. prefixes for easy access. The other is include files with language arrays to hold the static strings.
<?php $lang = array(); $lang['PAGE_TITLE'] = 'ABC Page'; $lang['HEADER_TITLE'] = 'What does ABC mean?'; $lang['SITE_NAME'] = 'ABC Website'; $lang['HEADING'] = 'ABC'; $lang['MENU_HOME'] = 'Home'; $lang['MENU_ABOUT'] = 'About Us'; $lang['MENU_CONTACT'] = 'Contact Us'; $lang['MENU_SITEMAP'] = 'Site Map'; ?>
Here is a brief list of some additional variables:
- Should you translate the URL as well? URL translation will generate multiple versions to the same URL.
- Do any of your target languages read RTL?
- Calendar, dates, times, currency, and numbers differ from a language to another.
- Research aspects related to different cultures like meaning of colors, preferred navigation and layout and the use of numeric characters.
- An important aspect of the translation process is translation itself, are you going to use machine or human translation? The first is cheaper, but the latter is much better in quality and is SEO friendly.
There are many ways to address localization and translation, your individual requirements will determine which is your best option. Each website/application is a different case with different needs and priorities, so you need to do some research before deciding on the most convenient way to implement localization and translation.