Skip to content

Translating app.electricitymaps.com

Viktor Andersson edited this page May 16, 2024 · 3 revisions

Creating a new locale

We use a combination of ISO 639-1 language codes and ISO 3166-1 alpha-2 country codes for our locale codes. The language code comes first, optionally followed by a country code if there are multiple locales for a language, separated by a hyphen (-). For example, Brazilian Portuguese is denoted by pt-br.

Create a file named YOUR_LOCALE.json in this directory with this content: "{}" (without the Double Quotation Marks). You will also need to update the files /web/src/translation/locales.ts and /web/index.html.

Then start using the tool as described below.

Translating strings missing in your locale

There are two ways of updating translations. If you are making bigger changes, then we recommend using the translation-helper.js tool, but if you are only making small changes, then using the GitHub editor might be easier.

Using the translation helper tool

This requires that you have cloned the repository and knows how to use git. See Getting started for more information.

We wrote a little tool for this task:

node translation-helper.js

You will be asked to select a language to translate.

Running the tool looks like this:

Languages you can translate: ar, da, de, es, fr, hr, it, ja, nl, pl, pt-br, ru, sv, zh-cn, zh-hk, zh-tw
Which language do you want to translate: de

country-panel.electricity [Electricity]: Elektrizität
zoneShortName.IQ-KUR.countryName [Iraq]: Irak
...

Using the GitHub editor

  1. Find the translation file here and open it.
  2. Press the edit icon
  3. Make changes to the translation
  4. Open a pull request with your changes
Clone this wiki locally