Languages
Can we limit the available languages?
locales/all.json
controls the available languages in the UI's drop down box.
It looks like the UI's language and the utterances' language are the same meaning that if you select English, you get the UI in English and you also get the utterances in English.
Default Language/Locale
To change the default locale, we need to change export const DEFAULT_LOCALE = 'mok';
in web/src/services/localization.ts
.
Note that the choice of DEFAULT_LOCALE
must be in the list locales/all.json
.
How to Add a New Language
Since we haven't found a wait to have the UI in one language and the utterances in another language, we've decided to add a new language code for the utterances and copy the localizations of English to that new language. Note that you need to chose a valid iso code or else Common-Voice will not accept it. You can find ISO-639-3 code here:
- List of ISO 639-3 codes then click the first letter of your code.
- List of ISO 639-1 codes
Let's see how to add str
to Common-Voice:
- Visit https://github.com/EveryVoiceTTS/common-voice and make sure you are on branch
dev/ilt
; - Add
str
tolocales/all.json
in order to get that new language to show up in the UI's top-right dropdown box; - Add
str
tolocales/contributable.json
. We weren't sure whatlocales/contributable.json
is for so we also addedstr
to it; - In order to get the new language name to properly show up in the UI, add its full name to
locales/native-names.json
. This looks like"str": "SENĆOŦEN Origin Stories",
.; - Again, we weren't sure what
locales/translated.json
is for and opted to addstr
; - We want the UI to be in English even for
str
, you will have to use the English localizations for your new language. We need to modify our templateweb/locales/en/messages.ftl
to add our new language code with its description.- Open
web/locales/en/messages.ftl
, - Find the proper
##Languages
section and addstr = SENĆOŦEN
, - Create a directory,
web/locales/str/
and copy the two filescross-locale.ftl
&messages.ftl
fromweb/locales/en/
toweb/locales/str/
,cp web/locales/en/* web/locales/str/
- We also need to update
messages.ftl
for all other locales. For this, copy the modifiedweb/locales/en/messages.ftl
to all otherweb/locales/*/
.
- Open
- Commit your changes;
- Wait for the new image to deploy the development;
- Validate your changes on https://staging.everyvoice.ca which is the development server;
- If your changes are correct, update the
ilt
branch withdev/ilt
; - Wait for the new image to deploy to the production environment;
- Finally, validate your changes on the production server https://studio.everyvoice.ca.
To add your sentences, you need to add them to https://github.com/EveryVoiceTTS/common-voice-corpora
under data/<ISO-639-3 Language Code>/
.
Note that Your corpora file MUST end with .txt
.
Generating Utterances
We also have a crude Lorem Ipsum generator but this is only meant to be used for testing.
mkdir -p server/data.ilt/git
mkdir -p server/data.ilt/str
./generator.py > server/data.ilt/git/utterances.txt
./generator.py > server/data.ilt/str/utterances.txt