2014-04-06 03:58:17 +02:00
Translations
============
2014-07-23 12:56:08 +02:00
How to translate Miniflux to a new language?
--------------------------------------------
2014-04-06 03:58:17 +02:00
- Translations are stored inside the directory `locales`
2015-12-08 03:05:31 +01:00
- There is a sub-directory for each language, for example in French we have `fr_FR` , Italian `it_IT` etc...
2014-04-06 03:58:17 +02:00
- A translation is a PHP file that return an Array with a key-value pairs
2015-12-08 03:05:31 +01:00
- The key is the original text in English and the value is the translation of the corresponding language
2015-02-08 16:58:03 +01:00
- **French translations are always up to date**
- Always use the last version (branch master)
2014-04-06 03:58:17 +02:00
2015-02-08 16:58:03 +01:00
### Plurals
2015-12-08 03:05:31 +01:00
Each translation file has a plural formula defined. This formula is used to determine whether a plural for the current number is needed. For languages with multiple plurals, the formula determine which plural form is the right one.
2015-02-08 16:58:03 +01:00
You can get the formula for your language from https://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html.
2015-12-08 03:05:31 +01:00
The formula need to be adjusted to be valid php code. Do not hesitate to ask for an adjusted formula in the bug tracker.
2015-02-08 16:58:03 +01:00
2015-12-08 03:05:31 +01:00
You need to create a list of strings for terms that have a plural. For example, the plural of the English translation looks like the following:
2015-02-08 16:58:03 +01:00
```
'plural' => function($n) { return ($n != 1); },
'After %d day' => array('After %d day', 'After %d days'),
```
2014-04-06 03:58:17 +02:00
2014-07-23 12:56:08 +02:00
### Create a new translation:
2014-04-06 03:58:17 +02:00
1. Make a new directory: `locales/xx_XX` by example `locales/fr_CA` for French Canadian
2. Create a new file for the translation: `locales/xx_XX/translations.php`
2015-02-08 16:58:03 +01:00
3. Use the content of the French locale and replace the values
2014-04-06 03:58:17 +02:00
4. Inside the file `models/config.php` , add a new entry for your translation inside the function `get_languages()`
5. Check with your local installation of Miniflux if everything is ok
2015-02-08 16:58:03 +01:00
6. Send a [pull-request with Github ](https://help.github.com/articles/using-pull-requests/ )
2014-07-23 12:56:08 +02:00
How to update an existing translation?
--------------------------------------
1. Open the translation file `locales/xx_XX/translations.php`
2015-02-08 16:58:03 +01:00
2. Missing translations are commented with `//` and the values are empty, just fill blank and remove the comment
3. Check with your local installation of Miniflux and send a [pull-request ](https://help.github.com/articles/using-pull-requests/ )
How to add new translated text in the application?
--------------------------------------------------
Translations are displayed with the following functions in the source code:
- `t()` : escaped HTML text
- `tne()` : displayed with no escaping
- `dt()` : date using `strftime()` formats
2015-12-08 03:05:31 +01:00
Always use the English version in the source code.
2015-02-08 16:58:03 +01:00
How to find missing translations in the applications?
-----------------------------------------------------
From a Unix shell run:
```bash
./scripts/find-strings.sh
```
2015-12-08 03:05:31 +01:00
All missing translations are displayed on the screen. Put that in the French locale and sync other locales (see below).
2015-02-08 16:58:03 +01:00
How to synchronize translation files?
-------------------------------------
From a Unix shell run this command:
```bash
./scripts/sync-locales.php
```
2015-12-08 03:05:31 +01:00
The French translation is used a reference to other locales.