Custom PHP Localization

September 4, 2016 Rabab Malek

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

gpi-php localization-home

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.

Summary

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.

Further Resources from GPI

You may gain further insight into global e-business, global SEO and website translation and country specific cultural facts and related topics by reviewing some previous blogs written by GPI:

Please feel free to contact GPI at info@globalizationpartners.com with any questions about our translation services.  Also let us know if you have any interesting blog topics you would like us to cover in future blogs. You may also request a complimentary Translation Quote for your projects as well.

 

 

About the Author

Rabab Malek

Rabab is a native Arabic speaker from Cairo, Egypt. She has over 12 years’ experience in software and websites architecture and implementation using open source programming tools including PHP, MySQL as well as jQuery, JSON and Ajax. She has served with various companies including Pyramid Technologies, Link-Dot-Net and InTouch Communications as a Programmer, Systems Engineer – Developer and Lead Web Developer. She earned her B.Sc. Degree in Economics with a minor in Computer Science from Cairo University. She completed a SSDP Diploma from the Information Technology Institute (IDSC), The Cabinet and is a certified Cloud Business Associate and a Microsoft Certified Professional (MCP, MCAD and MCSD.NET).

More Content by Rabab Malek
Previous Article
News: Globalization Partners International to Sponsor Sitecore Symposium
News: Globalization Partners International to Sponsor Sitecore Symposium

Sitecore Symposium 2016 is quickly approaching. It will be held September 14-16 in New Orleans, LA and GPI ...

Next Article
Sitecore – Exporting Content for Translation
Sitecore – Exporting Content for Translation

Sitecore is a leading Microsoft .NET based Web Content Management System (WCMS). Sitecore is highly scalabl...

Ready to translate your documents, software or website?

Request a Quote!