2.3 KiB
2.3 KiB
Localization Rules
- Files is separated by categories. DO NOT just stuff everything in
common. See below. - Include punctuations in the json. Duplicates are ok if necessary. For example:
{ "Friends": "Friends", "friends": "friends", "signOut?": "Sign out?", "signout": "Sign out" } - When creating files in
en, create the same files in the other language also, even if its an empty object. DO NOT give an empty string, empty string does not fallback toen - DO NOT have more that 1 first level key in the json file, because it is used in the script for importing the texts as filename.
- DO NOT fill other language files with english. Just leave the field blank, so that the translators know which one to translate.
- Check if your text available or not before you add new text.
- The key of your text should be related to the content, not to the component using it. This will help preventing duplicates.
- BE CAREFUL when changing the existing key, check for all occurrence of previous key.
IMPORTANT
NEVER do something like this:
i18n.t('common.friend').toLowerCase().concat('s')
Firstly, its the wrong category, should be friends.
Secondly, not all plural ends with s or es. For example, friend and friends:
- German: Freund and Freunde
- Chinese Simplified: 朋友 and 朋友们
Thirdly, toLowerCase is tolerable, but better not, because same as the reason above, you cannot guarantee all language follow the same rules.
Categories:
-
Common: anything that you cannot guess the category when you read it
-
Users:
- first / last name
- username
- password
- country
- accounts
- tnc / privacy
-
Contents:
- photo
- video
- item
- caption
- upload
- download
-
Albums
-
Playlists
-
Frames
-
Friends
Exception:
- Frame Settings
Updating languages copy
babel-node is a command that comes with @babel/node
npm i -g @babel/core @babel/node
Exporting
Output folder will be the folder where you run the command
babel-node src/locale/export-to-csv.js
Importing
babel-node src/locale/import-from-csv.js ./path/to/csv/lang.csv ./path/to/locale/folder
# example: babel-node src/locale/import-from-csv.js language.csv src/locale/lang/