Skip to content

How to add a new language on camptocamp

jphilippe edited this page Jun 7, 2024 · 7 revisions

The rules to add a new language to camptocamp are described in this article.

Add a new language for the UI

The first step is to add the new language on Transifex. See the Camptocamp Transifex Account, and an article on how to proceed as a translator.

The second step is to retrieve these ongoing translations on Github. This should be done in the following file: https://github.com/c2corg/c2c_ui/blob/master/.github/workflows/retrieve-i18n.yml

The next step is to add the language in the UI properly. You can inspired yourself from this PR, and be carefull to distinguish locale that are available as content in the API, and the one that are just for the UI.

Note that it is helpfull for translators to have access to the demo of the PR, to see what they are doing.

Add a new language in the API

See for example the addition of chinese and slovenian.

Remember to translate also the automated email (see this pull request).

In order to add languages and permit ES to index the content :

  1. update ES settings to create the language settings required for ES indexing process. The difference between the standard and the heavy is the icu_analyzer usage. (ES plugin)

       "index_slovene": {
             "type": "custom",
             "tokenizer": "standard",
             "filter": [
                 "autocomplete_filter",
                 "lowercase"
             ]
         },
         "slovene_heavy": {
             "tokenizer": "icu_tokenizer",
             "filter": [
                 "lowercase",
                 "icu_folding"
             ]
         },
         "index_chinois": {
             "type": "custom",
             "tokenizer": "standard",
             "filter": [
                 "autocomplete_filter"
             ]
         },
         "chinois_heavy": {
             "tokenizer": "icu_tokenizer",
             "filter": [
                 "lowercase",
                 "icu_folding"
             ]
         }
    
  2. Update indice mapping to produce the indexing based upon language settings

     "title_sl": {
     	"type": "text",
     	"index": false,
     	"fields": {
     		"ngram": {
     			"type": "text",
     			"analyzer": "index_ngram",
     			"search_analyzer": "search_ngram"
     		},
     		"raw": {
     			"type": "text",
     			"analyzer": "index_raw",
     			"search_analyzer": "search_raw"
     		},
     		"contentheavy": {
     			"type": "text",
     			"analyzer": "slovene_heavy"
     		}
     	}
     },
     "title_zh": {
     	"type": "text",
     	"index": false,
     	"fields": {
     		"ngram": {
     			"type": "text",
     			"analyzer": "index_ngram",
     			"search_analyzer": "search_ngram"
     		},
     		"raw": {
     			"type": "text",
     			"analyzer": "index_raw",
     			"search_analyzer": "search_raw"
     		},
     		"contentheavy": {
     			"type": "text",
     			"analyzer": "chinois_heavy"
     		}
     	}
     }
    
  3. Refresh the indice if it was not empty.