Translating
There are two ways to translate phrases:
- Manually translate generated JSON file by
php artisan fbt:generate-translations
and then use thephp artisan fbt:translate
command. - Manually add translations to the database and then use the
php artisan fbt:translate
command. - Use the app editor Swiftyper Translations.
Command to generate missing translation hashes from collected source strings:
⚠️ NOTE: This command is required only if you are using json
driver.
Options:
name | default | description |
---|---|---|
--src | FbtConfig::get('path') /.source_strings.json | Path to collected source strings file |
--translation-input | FbtConfig::get('path') /translation_input.json | Path to translation input file |
--translations=[path] | none | The translation files containing translations. E.g. --translations=./storage/fbt/translations/*.json |
Artisan command to convert provided translations to jenkins:
Options:
name | default | description |
---|---|---|
--pretty | no | Pretty print the translation output |
--translations=[path] | none | The translation files containing translations. If not specified, the translations are retrieved from the database. E.g. --translations=/path/to/translations/*.json |
--stdin < translation_input.json | none | Instead of reading translation files and source file separately, read monolithic JSON file from STDIN |
JSON schema:
In addition to the below example, the translation_input.json
provided in our tests
is a good reference on the "schema" used for the translations.
The <text_hash>
and <translation_hash>
correspond in the above example.
That is translations[<hash>]
is the translation entry for
phrases.hashToText[<hash>]
.
Here tokens
, types
and variations
are all associative arrays. That is, in
the above example, types[i]
represents the variation type (or mask) of
tokens[i]
and variations[i]
is the variation value of token[i]
for the
given translation entry.
Database schema:
Example translation:
fbt_phrases
translations
If you use tokens, they must be defined in same order and the following form: token_name
%token_type
.
...
Variation types
Variation types can be one of
This signifies what the given token can variate on. Token types of type GENDER
can be:
while token types of NUMBER
can be: