Programming in Website Localization

Proper Steps to Take During the Creation of a Website to Help Web Developers Avoid Common Pit-Falls During its Subsequent Localization

By Ricardo Alves,
Software Engineer
Ccaps Translation and Localization,
Rio de Janeiro, Brazil

rjunior@ccaps.net, www.ccaps.net

 

Continuing with our tips on the types of website programming and the ways to deal with these types for later localization, we will examine in this edition what can be done and how to do it.

 

There is not any tool that “understands” all the existing programming codes for client or server and makes available to translators only what really needs to be translated.

 

Some programs try to facilitate such task by highlighting what needs to be translated by following some of the patterns of each programming language. However, each programmer can use a great variety of techniques and programming methods, which allows for these tools to include programming codes into the translatable texts. During translation, the removal or addition of quotation marks, full stop, semi-colons or any other character used by the programming language may prevent the code from functioning.

 

To avoid accidents in the programming codes, files are usually pre-prepared for translation. Later on, the localization engineer (who must be acutely aware of the programming languages and the translation processes) reviews the pre-prepared files and makes the necessary adjustments to assure that only what needs to be translated is available.

This saves time and prevents problems related to code debugging. Hence, it will be easier to detect the problem and find a solution for it.

 

TIPS:

However, to avoid additional steps in the translation process the best choice is to have the developers change some (bad) habits that are commonplace in the creation of programming codes.

The following two examples demonstrate how the process is usually carried out and how it could be improved:

 

1. Never separate the parts of a text that will make a sentence when the code runs

For certain languages, the word order may have to be altered during the translation process. If the texts are separated, the correct translation of the sentence can become difficult. In the following example, the quotes are considered text qualifiers, which would break a sentence into two. The best method for this case then would be placeholder replacement. What follows is a Javascript example that will show the sentence “You are on page 3 of the open document.” in an alert box:

BAD

pag_num=”3″ ;
alert (“You are on page ” + pag_num + ” of the open document.”);

IDEAL

myString=”new” String(“You are on page %n of the open document.”);
rExp=”/” %n/gi;
pag_num=”3″ ;
results=”myString.replace” (rExp, pag_num);
alert (results);

 

2. Do not leave the translatable texts together with the code

Instead of making all texts hardcoded, it is preferable to declare constants in a file that is detached from the programming code. Therefore, the texts of this programming code can be translated in a separate file. This allows for the website logics (code) to not be necessarily edited, as the following example in Javascript using the same sentence above:

BAD

pag_num=”3″ ;
alert (“You are on page ” + pag_num + ” of the open document.”);

IDEAL

text.js
myString=”new” String(“You are on page %n of the open document.”);

code.html
<script SRC=”text.js”></script>
<script LANGUAGE=”Javascript”>

rExp=”/” %n/gi;
pag_num=”3″ ;
results=”myString.replace” (rExp, pag_num);
alert (results);

</script>

In our next edition, we will examine more tips on website programming to facilitate the localization process. We will also discuss the fourth type of programming mentioned in the first tip of this series: sites built on databases.

 

See you then!

For more information then see our website localisation service page here.

This article was originally published in Сcaps Newsletter (http://www.ccaps.net)