Reputation: 7035
I'm in the process of creating a web app in PHP which will be available in many different languages (about 10 in total), and I'd like to know what you view as best practice for setting this up in more general terms.
My idea is to keep all languages under the same domain, with a suffix such as "http://myservice.com/de", where a script performs a location check upon site entering and redirects the user.
Editorial content will be shared between all languages as single posts in the database with a specific data column for each language. Markup and scripts will all be documented in English, while pages and sections visible for the user will be translated into their respective language gathered from a common word library file.
A .htaccess file provides handling all rewrites for articles to display them in their appropriate language, i.e. "http://myservice.com/de/artikel/12345/" to "http://myservice.com/article?id=12345&lang=de".
What do you consider to be a clean and efficient multi-lingual setup?
Upvotes: 4
Views: 1865
Reputation: 1829
The best advice i can think of is dont do this yourself
An existing open source CMS (Content Management System) might be a good solution, rather than building one yourself. Naming two leading CMS systems: Drupal, Joomla. (there any MANY more options)
These systems offer many features that work either out of the box with some configuration, of by an extension plugin (thousands of plugins).
Internationalization is just one of them. probably with a richer and more robust feature set than you can do yourself.
also, these systems offer a extensive API for extending them with your own business logic.
Upvotes: 1
Reputation: 4015
Everybody has different opinions about how best to go about setting up an internationally-friendly website. However, I try not to reinvent the wheel by making my own system. Rather, I use the built in internationalisation and localisation tools in frameworks such as CakePHP.
From the CakePHP book;
One of the best ways for your applications to reach a larger audience is to cater for multiple languages. This can often prove to be a daunting task, but the internationalization and localization features in CakePHP make it much easier.
First, it’s important to understand some terminology. Internationalization refers to the ability of an application to be localized. The term localization refers to the adaptation of an application to meet specific language (or culture) requirements (i.e., a "locale"). Internationalization and localization are often abbreviated as i18n and l10n respectively; 18 and 10 are the number of characters between the first and last character.
http://book.cakephp.org/1.3/view/1228/Internationalization-Localization
Using the built-in tools, for me, offers an efficient way to translate applications without URL rewrites. It also means that a user can configure their localisation preferences and have them automatically applied every time they log in.
Such a method will also be considered more search-engine friendly because you won't get multilingual duplicates of the same content.
Hope this helps out.
Upvotes: 4