Version at: 22/02/2014, 18:44 vs. version at: 22/02/2014, 18:44
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
1212__() function
1313
1414CakePHP has several functions in this vein, but this is the function we will use most of the time. Note the pair of underscores.
1515
1616 __(‘some text’) => echo ‘some text’;
1717 __(‘some text’, true) => return ‘some text’;
1818
1919The language used in the code will be English.
2020
2121##Running cake i18n (on a Linux machine or virtual machine)
2222
2323 Open a console.
2424 Type : /var/http/tatoeba/cake/console/cake i18n
2525 Choose : E (Extract POT file from source)
2626 When asked if you want to merge all translations into a single file, say yes
2727 Type in the path to app: /home/tatoeba/tatoeba-www/app
2828 Type in the path to locale: /home/tatoeba/tatoeba-www/app/locale
2929 Choose a name for the file that will be generated (in this example, default.pot): default.pot
3030 Choose: Q (quit)
3131
32PO file
32##PO file
3333
3434Note: it may be better to use Launchpad to create a new UI language rather than follow this manual procedure.
3535
3636Adding a new language (e.g., French):
3737
3838 Create folder : /app/locale/fre/LC_MESSAGES
3939 Copy-paste default.pot in this folder
4040 Change it into default.po
4141 Open default.po with PoEdit (http://www.poedit.net/) and translate.
4242 Save. It will generate a *.mo file, which is used when replacing strings at runtime.
4343
4444If new strings are added:
4545
4646 Follow the cake i18n instructions to generate the up-to-date POT file.
4747 Open the PO file (PO, not POT).
4848 In the menu : Catalog > Update from POT file…
4949 Choose the POT file that was newly generated
5050
5151
52Switching languages
52##Switching languages
5353
5454The language of the page is set through the URL.
5555Example : http://localhost/tatoeba2/fre/sentences/index
5656Resources
5757
5858 http://blog.jaysalvat.com/articles/choix-des-langues-par-url-dans-cakephp.php
5959 http://www.formation-cakephp.com/41/multilingue-18n-l10n
6060
6161
6262
6363
diff view generated by jsdifflib

Version at: 22/02/2014, 18:44

#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 (on a Linux machine or virtual machine)

    Open a console.
    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)

PO file

Note: it may be better to use Launchpad to create a new UI language rather than follow this manual procedure.

Adding a new language (e.g., French):

    Create folder : /app/locale/fre/LC_MESSAGES
    Copy-paste default.pot in this folder
    Change it into default.po
    Open default.po with PoEdit (http://www.poedit.net/) and translate.
    Save. It will generate a *.mo file, which is used when replacing strings at runtime.

If new strings are added:

    Follow the cake i18n instructions to generate the up-to-date POT file.
    Open the PO file (PO, not POT).
    In the menu : Catalog > Update from POT file…
    Choose the POT file that was newly generated


Switching languages

The language of the page is set through the URL.
Example : http://localhost/tatoeba2/fre/sentences/index
Resources

    http://blog.jaysalvat.com/articles/choix-des-langues-par-url-dans-cakephp.php
    http://www.formation-cakephp.com/41/multilingue-18n-l10n



version at: 22/02/2014, 18:44

#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 (on a Linux machine or virtual machine)

    Open a console.
    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)

##PO file

Note: it may be better to use Launchpad to create a new UI language rather than follow this manual procedure.

Adding a new language (e.g., French):

    Create folder : /app/locale/fre/LC_MESSAGES
    Copy-paste default.pot in this folder
    Change it into default.po
    Open default.po with PoEdit (http://www.poedit.net/) and translate.
    Save. It will generate a *.mo file, which is used when replacing strings at runtime.

If new strings are added:

    Follow the cake i18n instructions to generate the up-to-date POT file.
    Open the PO file (PO, not POT).
    In the menu : Catalog > Update from POT file…
    Choose the POT file that was newly generated


##Switching languages

The language of the page is set through the URL.
Example : http://localhost/tatoeba2/fre/sentences/index
Resources

    http://blog.jaysalvat.com/articles/choix-des-langues-par-url-dans-cakephp.php
    http://www.formation-cakephp.com/41/multilingue-18n-l10n



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.