# Internationalization¶

## Translation files¶

Translations are just a simple JSON file. This is a mapping table between English and the language, for example:

{
"Unable to parse Atom feed: %v.": "Impossible de lire ce flux Atom: %v."
}


Placeholders are the ones used by the package fmt.

## Plural forms¶

Some languages have different rules regarding plurals. These rules are defined in the file locale/plurals.go. You could add more rules if yours is not available.

In the JSON file, a plural translation is defined like that:

{
"plural.feed.error_count": [
"%d error",
"%d errors"
]
}


This example is for the English language, the plural form is plurals=2; plural=(n != 1);. For one error, we will have 1 error, for 2 or more errors: 3 errors.

You could find the different plural forms here:

## How to add a new language?¶

### 1) Checkout the source code from the repository¶

Fork the project, fetch the source code locally and add your fork as Git remote (Details).

### 2) Create a new translation file¶

• In the folder locale/translations, create a new JSON file, for example, de_DE.json for German.
• You could copy the translations from fr_FR.json and replace the strings.

### 3) Add the language to the list¶

Open the file locale/locale.go, and edit the function AvailableLanguages().

func AvailableLanguages() map[string]string {
return map[string]string{
"en_US": "English",
"fr_FR": "Français",
}
}


This function returns a mapping table of available languages. On the left, you have the language code and on the right the language name written in native language.

### 4) Test the translations¶

Translation files are embedded into the application executable. You must compile the software to see the changes.

make run


You must have a local development environment configured properly.

### 5) Create a branch and send a pull-request¶

Your pull-request should contains only 3 files:

• locale/translations/xx_XX.json
• locale/locale.go
• locale/translations.go

If you don’t know how to send a pull-request, here is the documentation of GitHub: https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request