Multilingual website - how to translate a website into different languages
Usually the site is developed for one specific language and is hosted on the domain in the national zone - ru, en, de , etc. However, later it becomes necessary to expand the audience of the site by attracting users from other countries. Of course, they can use the built-in translators in the browser, but this method is not entirely accurate and convenient. In addition, users simply will not find such a site in the search if it is in another language.
A better option is to provide a multilingual site . This allows you to provide content in a form convenient for each user, because information is best perceived in the native language.
In order to translate the site into different languages , it is necessary to provide for what method will be used. Conventionally, there are three ways:
- Partial , which translates only the most used words;
- Service , in which only the administrative parts of the system are subject to translation;
- Full , which implies the translation of all available data in the system.
Which method to use depends on your specific needs, but it will probably be more convenient for the administrator to use their own language and users in other languages. In this case, the language can be automatically detected for each user. Translation of site content into different languages should be done in a comprehensive manner, both lines of text in the code and user-generated content added using forms should be taken into account.
Any scheme for translating existing string phrases can be used, examples:
- preliminary data collection and subsequent translation can be used ;
- content can be translated in real time using third party translation services API .
Manually translated strings can be stored in a pre-prepared store, which can be a table in a database with the required columns. In this case, the collection of lines of text can be organized using a special method in the code, which will check whether such a line exists in the database and, if necessary, add it. Later, you can download all the strings from the table in a convenient format (using a similar pre-developed functionality) and translate them, all you have to do is load the translated strings into the database for a specific language.
Site language can be detected automatically, as mentioned earlier, and it is also worth placing a panel for switching the language in a convenient place on the site - this can be useful for cases when the language is determined incorrectly for some reason or the user prefers a different language. You can remember the choice of the site language using Cookie so that the user does not have to switch the site language every time.
The site can be multilingual and at the same time have the same page addresses, that is, without additional insertion of the language code into the URL . At the same time, pages in different languages will be indexed by search engines and available in search, but this depends on whether the search engine has cookie support.
In the case of using ready-made CMS or similar systems for building a site, localization tools are usually available in such systems.
For example, in CMS Drupal there is support for "gettext" (the GNU project library for internationalization), which allows you to prepare files for translation in a special format (.po). There are entire translation projects for this system that provide translations via remote requests - this makes it possible to almost automatically use translations for the core, modules, themes and other entities of the system. However, the translation of user-generated content remains with the administration of a particular site. For this, special modules and system capabilities can be used. The text in your code should be wrapped in a function t , which places a string in a database table and requests a translation from another table that stores the translations.
- 09.07.22IT / Misc Convert office files DOC, DOCX, DOCM, RTF to DOCX, DOCM, DOC, RTF, PDF, HTML, XML, TXT formats without loss and markup changes
- 07.07.22IT / Safety How to protect PHP, JS, HTML, CSS source code - obfuscation, minification, compression and encryption
- 06.07.22IT / Safety Connection not secure, problem with Lets Encrypt - how to fix expired 09/30/2021 DST Root CA X3, remove it manually and install ISRG Root X1. Example on MS Windows 7
- 08.07.21IT / Misc How to make a free translation for a website without an API, translate documents in Google Translate
- 06.07.21IT / Misc How to make a subscription button on a website, a subscriber base and automatic mailing