Version at: 23/02/2014, 01:15 vs. version at: 23/02/2014, 01:20
11#Extracting UI Strings
22
33These instructions describe how to extract UI strings so that they can be translated. The original source of these instructions, stored on Assembla, is here: [1]
44
55 [1]: https://www.assembla.com/spaces/tatoeba2/wiki/Internationalization
66
77
88##Markup for internationalized strings in the code
99
1010In the code, whenever developers write strings that will have to be translated, they use a special function whose name consists of a double underscore. A script (CakePHP's "i18n extract" script) can later be run to scan the code and extract the strings that are passed to this function.
1111
12__() function
13
14CakePHP has several functions in this vein, but this is the function we will use most of the time. Note the pair of underscores.
15
12Examples:
1613 __(‘some text’) => echo ‘some text’;
1714 __(‘some text’, true) => return ‘some text’;
1815
1916The language used in the code will be English.
2017
2118##Running cake i18n
2219
2320* Open a console on a Linux machine or Linux virtual machine.
2421* Type : /var/http/tatoeba/cake/console/cake i18n
2522* Choose : E (Extract POT file from source)
2623* When asked if you want to merge all translations into a single file, say yes
2724* Type in the path to app: /home/tatoeba/tatoeba-www/app
2825* Type in the path to locale: /home/tatoeba/tatoeba-www/app/locale
2926* Choose a name for the file that will be generated (in this example, default.pot): default.pot
3027* Choose: Q (quit)
3128
3229
3330
3431
3532
diff view generated by jsdifflib

Version at: 23/02/2014, 01:15

#Extracting UI Strings

These instructions describe how to extract UI strings so that they can be translated. The original source of these instructions, stored on Assembla, is here: [1]

  [1]: https://www.assembla.com/spaces/tatoeba2/wiki/Internationalization


##Markup for internationalized strings in the code

In the code, whenever developers write strings that will have to be translated, they use a special function whose name consists of a double underscore. A script (CakePHP's "i18n extract" script) can later be run to scan the code and extract the strings that are passed to this function.

__() function

CakePHP has several functions in this vein, but this is the function we will use most of the time. Note the pair of underscores.

    __(‘some text’) => echo ‘some text’;
    __(‘some text’, true) => return ‘some text’;

The language used in the code will be English.

##Running cake i18n

* Open a console on a Linux machine or Linux virtual machine.
* Type : /var/http/tatoeba/cake/console/cake i18n
* Choose : E (Extract POT file from source)
* When asked if you want to merge all translations into a single file, say yes
* Type in the path to app: /home/tatoeba/tatoeba-www/app
* Type in the path to locale: /home/tatoeba/tatoeba-www/app/locale
* Choose a name for the file that will be generated (in this example, default.pot): default.pot
* Choose: Q (quit)




version at: 23/02/2014, 01:20

#Extracting UI Strings

These instructions describe how to extract UI strings so that they can be translated. The original source of these instructions, stored on Assembla, is here: [1]

  [1]: https://www.assembla.com/spaces/tatoeba2/wiki/Internationalization


##Markup for internationalized strings in the code

In the code, whenever developers write strings that will have to be translated, they use a special function whose name consists of a double underscore. A script (CakePHP's "i18n extract" script) can later be run to scan the code and extract the strings that are passed to this function.

Examples:
    __(‘some text’) => echo ‘some text’;
    __(‘some text’, true) => return ‘some text’;

The language used in the code will be English.

##Running cake i18n

* Open a console on a Linux machine or Linux virtual machine.
* Type : /var/http/tatoeba/cake/console/cake i18n
* Choose : E (Extract POT file from source)
* When asked if you want to merge all translations into a single file, say yes
* Type in the path to app: /home/tatoeba/tatoeba-www/app
* Type in the path to locale: /home/tatoeba/tatoeba-www/app/locale
* Choose a name for the file that will be generated (in this example, default.pot): default.pot
* Choose: Q (quit)




Note

The lines in green are the lines that have been added in the new version. The lines in red are those that have been removed.