coinos can be translated into other languages by editing JSON files. You do not need programming knowledge to do this, or to use these instructions. Here are instructions on how to translate coinos:
NOTE: This guide was written for people without a technical background. If you want more technical details, click here.
These instructions assume you have a GitHub account and have permission to modify this repository. If you do not have permission, you will need to make a fork using the link on the top-right, then follow these instructions to translate your fork, then make a pull request using the link below the "Code" button to apply your changes to the main repository.
Last Updated: 2022-08-23
Before you can translate coinos, you need to know the ISO 639-1 code of your language. This is a standard two-letter code that your browser uses to refer to a language (for example, English is en
, and Spanish is es
). You can also add a dash and more letters to refer to a specific region (for example, American English is en-US
, and British English is en-GB
). A list of all codes can be found here, and Firefox-based browsers show you the code when you are selecting your browser's language.
Each translation of coinos is stored in a special locale file. These files can be found in the src/locales
folder in the coinos directory. The name of these files is the language code plus ".json
". A file might look something like this:
{
"howItWorks": "How it works",
"faq": "FAQ",
"about": "About",
"startInSeconds": "Start in Seconds",
"signIn": "Sign In"
}
Each line (other than the opening and closing braces) contains a text name, then a colon (:
), then the translated text. All lines other than the last end in a comma. The text name is a word that is the same in all translations, and is used by the code to access that piece of text. Both the text name and translated text must be inside quotation marks ("
).
There is also a JSON file that controls which languages are understood. It is at src/lib/translations/lang.json
and looks something like this:
{
"en": "English",
"fr": "Français",
"es": "Español"
}
This file simply maps each language to its name. It is used both to get a list of languages and to get the name of each language for the language selector. If a translation is not in this file, coinos will not be able to see it.
You might notice that some of the left-text in the language files don't have a string after them, instead having some {}
curly brackets, like in this example:
"nav": {
"startInSeconds": "Start in Seconds",
"account": "Account",
"signIn": "Sign In",
"signOut": "Sign Out",
"dashboard": "Dashboard",
"settings": "Settings",
"support": "Support"
},
These denote sections of the JSON file, which helps keep it organized. If you're translating some text that is in a section, make sure the translated text is in the same section of the new file. If that section doesn't exist, just create it.
In the translation files, sections roughly correspond to where the the text is in coinos. This can be useful if you need context for some text. Here are some of these associations (A.B
means section B
is located inside A
):
Section | Location |
---|---|
404 | the 404 page |
about | the 'About' section at the bottom of the homepage |
error | the error page |
faq | the FAQ on the homepage |
footer | the bottom of the homepage |
howItWorks | the 'How it Works' section |
invoice | the Invoice page |
jobs | the Jobs page |
landing | the top of the homepage |
login | the Register and Login pages |
user | the user page |
user.dashboard | the user's dashboard |
user.settings | the settings page |
user.support | the user's support page |
user.transactions | the user's transaction history page |
Sometimes, you will see strange text surrounded with <>
angle brackets. Every one of these "HTML tags" will be followed by another one starting with a slash. Here's an example:
"p1": "<strong>coinos</strong> is an <strong>open source</strong> bitcoin web wallet, point of sale, ecommerce marketplace and exchange platform. Development started in Vancouver in September 2012 as a way to provide local merchants with a convenient way to accept bitcoin payments.",
These apply a certain style to the text between them. For example, the tags above will make "coinos" and "open source" bold, leaving the rest non-bold.
When translating strings containing tags, don't change the tags. Do translate the text between them, and don't be afraid to move them around - just make sure they contain the same part of the sentence, and that the one without the slash is always before the one with the slash. Not all of the localizable strings support HTML tags, so you shouldn't use them if they aren't in the original string you're translating.
Follow these steps to create a new translation. You will need a GitHub account to do this:
- Determine the language code of your language, using this list. For these instructions, I will be using the fictional code
xx
- replace that code with the code of whatever language you are translating to. - Go to the
src
folder, then thelocales
folder, then create a filexx.json
inside that folder using either a text editor (e.g. Notepad), or GitHub. - Copy the text from
en.json
into this new file. - Translate all of the pieces of text on the right. Do not translate or alter in any way the pieces of text on the left, or any line that doesn't have two pieces of text!
NOTE: "coinos" is a feminine noun in languages with grammatical gender. - Scroll down and use the green button to commit the file.
- Go to the
src
folder again, thenlib
, thentranslations
, thenlang.json
. - Use the pencil icon on the top-right to edit the file, then add a new line containing your language code in quotes, followed by a colon, followed by the full name of your language in quotes. Make sure every line except the last has a comma at the end.
- Commit your changes like you did in step 5.
Follow these steps to add to an existing translation. You will also need a GitHub account to do this:
- Determine the language code of your language, using this list. For these instructions, I will be using the fictional code
xx
- replace that code with the code of whatever language you are translating to. - Go to the
src
folder, thenlocales
, thenen.json
. - Find the line with the piece of text that you want to translate.
- Find your translation's file, at
src/locales/xx.json
. - Use the pencil icon on the top-right to edit the file.
- Add the whole line (both left and right parts) from step 3 to this file, in between the
{}
braces. Make sure the previous line has a comma at the end, and that it is in the same place as before (i.e. inside the same set of{}
braces - if they don't exist, create them). - Translate the piece of text on the right, keeping the quotes surrounding it. Do not translate or alter in any way the piece of text on the left, or any line that doesn't have two pieces of text!
NOTE: "coinos" is a feminine noun in languages with grammatical gender. - Repeat steps 3-7 for every piece of text you want to translate (you should probably open
en.json
in another tab, so that your changes from step 6 aren't erased). - Scroll down and use the green button to commit the file.
There is also a program that helps you translate automatically - all you have to do is input the translated text and it will do the rest for you! You need a bit of technical knowledge to use it however, specifically, you need to know:
The script also shows you the ID of each bit of text you are translating, so that you can know where it is. A.B
means string B
in section A
, A.B.C
means string C
in subsection B
in section A
, etc.
Clone the repository, then use the guided translation script (at src/locales/guided_translation.py
) to update the translation files. You will need to pull before running, and commit/push your changes in order for them to be applied to coinos.