Best practice for multilingual PHP web application framework

I am creating a web application in PHP that will be available in different languages ​​(about 10 in total), and I would like to know what you consider to be the best practice for setting this up in more general terms.

My idea is to keep all languages ​​in the same domain with a suffix, for example "http://myservice.com/de", where the script checks the location on the site, entering and redirecting the user.

Editorial content will be shared between all languages ​​as separate entries in the database with a specific data column for each language. The markup and scripts will be documented in English, and the pages and sections visible to the user will be translated into their respective language, collected from a common word library file.

The .htaccess file allows you to process all rewrites for articles in order to display them in the corresponding language, for example, "http://myservice.com/de/artikel/12345/", to "http://myservice.com/article? ID = 12345 & id = de "

What do you consider a clean and efficient multilingual setup?

+4
source share
3 answers

Everyone has different opinions on how best to create an internationally friendly website. However, I try not to reinvent the wheel by creating my own system. Rather, I use built-in internationalization and localization tools in frameworks such as CakePHP.

From CakePHP;

One of the best ways to get your apps to a wider audience is to serve multiple languages. This can often be challenging, but CakePHP's internationalization and localization features make it easy.

First, it’s important to understand some terminology. Internationalization means the ability to localize an application. The term “localization” refers to the adaptation of an application to meet the requirements of a particular language (or culture) (ie, “Locale”). Internationalization and localization are often abbreviated as i18n and l10n respectively; 18 and 10 - the number of characters between the first and last characters.

http://book.cakephp.org/1.3/view/1228/Internationalization-Localization

Using built-in tools for me offers an efficient way to translate applications without rewriting URLs. It also means that the user can configure their localization settings and automatically apply them each time they log in.

This method will also be considered more convenient for search engines, because you will not receive multilingual duplicates of the same content.

Hope this helps.

+4
source

The best advice I can come up with is not to do it on my own

An existing open source CMS (content management system) may be a good solution, rather than creating it yourself. The names of the two leading CMS systems: Drupal, Joomla. (there are MANY options)

These systems offer many features that work either out of the box with some configuration, or using 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.

these systems also offer an extensive API to extend their own business logic.

+1
source

If you are using ASP.NET (MVC 2 or 3), I suggest reading this article. I think this is one of the best practices in .NET.

0
source

Source: https://habr.com/ru/post/1389052/


All Articles