Version at: 04/03/2014, 00:40 vs. version at: 06/03/2014, 00:13
11# Adding a New Language to the Corpus (for Developers)
22
33##Introduction
44
55These are the instructions for adding a language to the Tatoeba corpus. Instructions for adding a language in which the Tatoeba UI will be displayed are found elsewhere.
66
77These instructions were modified from [Assembla](https://www.assembla.com/spaces/tatoeba2/wiki/Adding_a_language_in_Tatoeba). **The sections from "In Your Local Tatoeba" onwards have not been updated yet.**
88
99##FAQ for users
1010The FAQ for users who want to add a new language: [How to request a new language](http://tatoeba.org/eng/faq#new-language).
1111
1212##Language icon
13131. Create the icon for the language. The icon should be a PNG file of dimension 30x20. On each icon there is (in theory) a 1px line of color #dcdcdc on the border bottom and right. Most of the icons also have gone through a luminosity change, so that they are a bit more pale than the original image. Anyway, most of it doesn't matter right now. The most important is that the icon is a PNG file of dimension 30x20.
1414
15152. Commit the image to the repository. The icons are stored in the app/webroot/img/flags folder. Ask one of the people with repository access if you don't have it yourself and don't want to obtain it.
1616
17173. Update the app/webroot/img/flags directory on the server, to retrieve the new images for the new languages.
1818
1919##Source code
2020
2121There is a script that was used on the server to modify the right files to add the new language code to the appropriate files. As of 2014-03-02, an updated version of the [script](https://github.com/Tatoeba/tatoeba2/blob/master/docs/add_lang.sh) has been checked into our repository, though the script has not been uploaded to the server yet. The script takes the following parameters:
2222
2323* three-letter ISO 639-code (e.g., "epo" for Esperanto")
2424* the English name of the language (e.g., "Esperanto")
2525* the ID of a list containing at least 5 sentences in the given language (to find the ID of the language, search the [list of lists](http://tatoeba.org/eng/sentences_lists/index) for the appropriate list, then roll over it with your mouse to see the URL, which contains the list ID)
2626* the string "dev" (on a development machine) or "prod" (on the server)
2727* the username for the database
2828* the password for the database
2929* the database name
3030
3131Once this script is executed, the new languages will be available on the website. The sentences that were in the list with id <list_id> will have their language set to the new language (instead of being set to language unknown). This script edits the following files:
3232
3333* **app/model/sentence.php**
3434Adds the language ISO code to the $validate array. Languages that are not part of this array are not allowed.
3535
3636* **app/views/helpers/languages.php**
3737Adds the language ISO code and the name to the languagesArray() method.
3838
3939* **docs/generate\_sphinx\_conf.php**
4040Adds the language ISO code and name to the $languages array. Also adds the ISO code to the $cjkLanguages array if the language uses Chinese, Japanese or Korean characters.
4141
4242
4343In the past, we used to edit this:
4444
4545* **app/controllers/components/google\_language\_api.php**
4646Adds the corresponding case to the google2TatoebaCode() method, if Google supports the detection for the language. See the Language enum.
4747
4848but now tatodetect takes care of language detection.
4949
5050After you make your changes, commit your code to the repository, or have someone do it for you. See [Repositories](repositories).
5151
5252##In your local Tatoeba
53
54**This section has not been updated yet.**
5355
5456* Connect to mysql and select the database.
5557* If you haven't done it yet, run the following script:
5658 docs/database/scripts/add\_new\_language.sql.
5759It will create a procedure to easily add a new language and do the necessary updates in the database.
5860* CALL add_new_language(iso\_code, list\_id, tag_name);
5961* Read the comments in add\_new\_language.sql to have examples of the procedure.
6062* Test that the language detection works (or can work) by adding a sentence with 'auto-detect'. There should be on Tatoeba a list of sentences in the language in question (named after the language in question).
6163* Test that you can change the language of a sentence into the language in question.
6264* Check that the count displays properly in the languages stats.
6365* If it's all fine, commit and refer to the ticket #225 in your comment (=> re #225) and indicate the languages that were added. Also refer to any separate tickets that were added to track adding these languages in particular. The syntax for referring to multiple tickets is described here.
6466
6567
6668##On the dev
69
70**This section has not been updated yet.**
6771
6872* Go to the 'dev' repository.
6973* Update it, if necessary.
7074* Connect to the mysql database of the dev version.
7175* CALL add\_new\_language(iso_code, list_id, tag_name);
7276* Test the same things you have tested in local.
7377
7478
7579##On the prod
80
81**This section has not been updated yet.**
7682
7783* If everything is fine with the dev, go to the 'prod' repository.
7884* htop
7985* Check that the load is below 2.
8086* Update the repository if necessary
8187* Connect to the mysql database of the prod version.
8288* CALL add\_new\_language(iso_code, list_id, tag_name);
8389* exit
8490* Check that the sentences that were in the list and tags have now the appropriate icon.
8591* Check that the language appears in the languages stats.
8692* cp /usr/local/etc/sphinx.conf /usr/local/etc/sphinx.conf.old
8793* php generate\_sphinx\_conf.php > /usr/local/etc/sphinx.conf
8894* Change the necessary things in the new config file (user, password, database and port). Look at the old conf file for reference.
8995* indexer --all --rotate & disown
9096
9197##Historical information only
9298We used to follow this procedure for adding a new language (example: French):
9399
94100* Create folder : /app/locale/fre/LC_MESSAGES
95101* Copy-paste default.pot into this folder
96102* Change it into default.po
97103* Open default.po with PoEdit (http://www.poedit.net/) and translate.
98104* Save. It will generate a *.mo file, which is used when replacing strings at runtime.
99105
100106and when new strings were added:
101107
102108* Follow the cake i18n instructions to generate the up-to-date POT file.
103109* Open the PO file (PO, not POT).
104110* In the menu : Catalog > Update from POT file…
105111* Choose the POT file that was newly generated
106112
107113The language of the page is set through the URL.
108114Example: http://localhost/tatoeba2/fre/sentences/index
109115
110116Resources:
111117
112118* http://blog.jaysalvat.com/articles/choix-des-langues-par-url-dans-cakephp.php
113119* http://www.formation-cakephp.com/41/multilingue-18n-l10n
114120
diff view generated by jsdifflib

Version at: 04/03/2014, 00:40

# Adding a New Language to the Corpus (for Developers)

##Introduction

These are the instructions for adding a language to the Tatoeba corpus. Instructions for adding a language in which the Tatoeba UI will be displayed are found elsewhere.

These instructions were modified from [Assembla](https://www.assembla.com/spaces/tatoeba2/wiki/Adding_a_language_in_Tatoeba). **The sections from "In Your Local Tatoeba" onwards have not been updated yet.**

##FAQ for users
The FAQ for users who want to add a new language: [How to request a new language](http://tatoeba.org/eng/faq#new-language).

##Language icon
1. Create the icon for the language. The icon should be a PNG file of dimension 30x20. On each icon there is (in theory) a 1px line of color #dcdcdc on the border bottom and right. Most of the icons also have gone through a luminosity change, so that they are a bit more pale than the original image. Anyway, most of it doesn't matter right now. The most important is that the icon is a PNG file of dimension 30x20.

2. Commit the image to the repository. The icons are stored in the app/webroot/img/flags folder. Ask one of the people with repository access if you don't have it yourself and don't want to obtain it.

3. Update the app/webroot/img/flags directory on the server, to retrieve the new images for the new languages.

##Source code

There is a script that was used on the server to modify the right files to add the new language code to the appropriate files. As of 2014-03-02, an updated version of the [script](https://github.com/Tatoeba/tatoeba2/blob/master/docs/add_lang.sh) has been checked into our repository, though the script has not been uploaded to the server yet. The script takes the following parameters:

* three-letter ISO 639-code (e.g., "epo" for Esperanto")
* the English name of the language (e.g., "Esperanto")
* the ID of a list containing at least 5 sentences in the given language (to find the ID of the language, search the [list of lists](http://tatoeba.org/eng/sentences_lists/index) for the appropriate list, then roll over it with your mouse to see the URL, which contains the list ID)
* the string "dev" (on a development machine) or "prod" (on the server)
* the username for the database
* the password for the database
* the database name

Once this script is executed, the new languages will be available on the website. The sentences that were in the list with id <list_id> will have their language set to the new language (instead of being set to language unknown). This script edits the following files:

* **app/model/sentence.php**
Adds the language ISO code to the $validate array. Languages that are not part of this array are not allowed.

* **app/views/helpers/languages.php**
Adds the language ISO code and the name to the languagesArray() method.

* **docs/generate\_sphinx\_conf.php**
Adds the language ISO code and name to the $languages array. Also adds the ISO code to the $cjkLanguages array if the language uses Chinese, Japanese or Korean characters.

 
In the past, we used to edit this:

* **app/controllers/components/google\_language\_api.php**
Adds the corresponding case to the google2TatoebaCode() method, if Google supports the detection for the language. See the Language enum.

but now tatodetect takes care of language detection.

After you make your changes, commit your code to the repository, or have someone do it for you. See [Repositories](repositories).

##In your local Tatoeba

* Connect to mysql and select the database.
* If you haven't done it yet, run the following script: 
 docs/database/scripts/add\_new\_language.sql. 
It will create a procedure to easily add a new language and do the necessary updates in the database.
* CALL add_new_language(iso\_code, list\_id, tag_name);
* Read the comments in add\_new\_language.sql to have examples of the procedure.
* Test that the language detection works (or can work) by adding a sentence with 'auto-detect'. There should be on Tatoeba a list of sentences in the language in question (named after the language in question).
* Test that you can change the language of a sentence into the language in question.
* Check that the count displays properly in the languages stats.
* If it's all fine, commit and refer to the ticket #225 in your comment (=> re #225) and indicate the languages that were added. Also refer to any separate tickets that were added to track adding these languages in particular. The syntax for referring to multiple tickets is described here. 

 
##On the dev

* Go to the 'dev' repository.
* Update it, if necessary.
* Connect to the mysql database of the dev version.
* CALL add\_new\_language(iso_code, list_id, tag_name);
* Test the same things you have tested in local. 

 
##On the prod

* If everything is fine with the dev, go to the 'prod' repository.
* htop
* Check that the load is below 2.
* Update the repository if necessary
* Connect to the mysql database of the prod version.
* CALL add\_new\_language(iso_code, list_id, tag_name);
* exit
* Check that the sentences that were in the list and tags have now the appropriate icon.
* Check that the language appears in the languages stats.
* cp /usr/local/etc/sphinx.conf /usr/local/etc/sphinx.conf.old
* php generate\_sphinx\_conf.php > /usr/local/etc/sphinx.conf
* Change the necessary things in the new config file (user, password, database and port). Look at the old conf file for reference.
* indexer --all --rotate & disown

##Historical information only
We used to follow this procedure for adding a new language (example: French):

* Create folder : /app/locale/fre/LC_MESSAGES
* Copy-paste default.pot into 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.

and when new strings were 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

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: 06/03/2014, 00:13

# Adding a New Language to the Corpus (for Developers)

##Introduction

These are the instructions for adding a language to the Tatoeba corpus. Instructions for adding a language in which the Tatoeba UI will be displayed are found elsewhere.

These instructions were modified from [Assembla](https://www.assembla.com/spaces/tatoeba2/wiki/Adding_a_language_in_Tatoeba). **The sections from "In Your Local Tatoeba" onwards have not been updated yet.**

##FAQ for users
The FAQ for users who want to add a new language: [How to request a new language](http://tatoeba.org/eng/faq#new-language).

##Language icon
1. Create the icon for the language. The icon should be a PNG file of dimension 30x20. On each icon there is (in theory) a 1px line of color #dcdcdc on the border bottom and right. Most of the icons also have gone through a luminosity change, so that they are a bit more pale than the original image. Anyway, most of it doesn't matter right now. The most important is that the icon is a PNG file of dimension 30x20.

2. Commit the image to the repository. The icons are stored in the app/webroot/img/flags folder. Ask one of the people with repository access if you don't have it yourself and don't want to obtain it.

3. Update the app/webroot/img/flags directory on the server, to retrieve the new images for the new languages.

##Source code

There is a script that was used on the server to modify the right files to add the new language code to the appropriate files. As of 2014-03-02, an updated version of the [script](https://github.com/Tatoeba/tatoeba2/blob/master/docs/add_lang.sh) has been checked into our repository, though the script has not been uploaded to the server yet. The script takes the following parameters:

* three-letter ISO 639-code (e.g., "epo" for Esperanto")
* the English name of the language (e.g., "Esperanto")
* the ID of a list containing at least 5 sentences in the given language (to find the ID of the language, search the [list of lists](http://tatoeba.org/eng/sentences_lists/index) for the appropriate list, then roll over it with your mouse to see the URL, which contains the list ID)
* the string "dev" (on a development machine) or "prod" (on the server)
* the username for the database
* the password for the database
* the database name

Once this script is executed, the new languages will be available on the website. The sentences that were in the list with id <list_id> will have their language set to the new language (instead of being set to language unknown). This script edits the following files:

* **app/model/sentence.php**
Adds the language ISO code to the $validate array. Languages that are not part of this array are not allowed.

* **app/views/helpers/languages.php**
Adds the language ISO code and the name to the languagesArray() method.

* **docs/generate\_sphinx\_conf.php**
Adds the language ISO code and name to the $languages array. Also adds the ISO code to the $cjkLanguages array if the language uses Chinese, Japanese or Korean characters.

 
In the past, we used to edit this:

* **app/controllers/components/google\_language\_api.php**
Adds the corresponding case to the google2TatoebaCode() method, if Google supports the detection for the language. See the Language enum.

but now tatodetect takes care of language detection.

After you make your changes, commit your code to the repository, or have someone do it for you. See [Repositories](repositories).

##In your local Tatoeba

**This section has not been updated yet.**

* Connect to mysql and select the database.
* If you haven't done it yet, run the following script: 
 docs/database/scripts/add\_new\_language.sql. 
It will create a procedure to easily add a new language and do the necessary updates in the database.
* CALL add_new_language(iso\_code, list\_id, tag_name);
* Read the comments in add\_new\_language.sql to have examples of the procedure.
* Test that the language detection works (or can work) by adding a sentence with 'auto-detect'. There should be on Tatoeba a list of sentences in the language in question (named after the language in question).
* Test that you can change the language of a sentence into the language in question.
* Check that the count displays properly in the languages stats.
* If it's all fine, commit and refer to the ticket #225 in your comment (=> re #225) and indicate the languages that were added. Also refer to any separate tickets that were added to track adding these languages in particular. The syntax for referring to multiple tickets is described here. 

 
##On the dev

**This section has not been updated yet.**

* Go to the 'dev' repository.
* Update it, if necessary.
* Connect to the mysql database of the dev version.
* CALL add\_new\_language(iso_code, list_id, tag_name);
* Test the same things you have tested in local. 

 
##On the prod

**This section has not been updated yet.**

* If everything is fine with the dev, go to the 'prod' repository.
* htop
* Check that the load is below 2.
* Update the repository if necessary
* Connect to the mysql database of the prod version.
* CALL add\_new\_language(iso_code, list_id, tag_name);
* exit
* Check that the sentences that were in the list and tags have now the appropriate icon.
* Check that the language appears in the languages stats.
* cp /usr/local/etc/sphinx.conf /usr/local/etc/sphinx.conf.old
* php generate\_sphinx\_conf.php > /usr/local/etc/sphinx.conf
* Change the necessary things in the new config file (user, password, database and port). Look at the old conf file for reference.
* indexer --all --rotate & disown

##Historical information only
We used to follow this procedure for adding a new language (example: French):

* Create folder : /app/locale/fre/LC_MESSAGES
* Copy-paste default.pot into 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.

and when new strings were 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

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.