Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add French as a default language #962

Merged
merged 5 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2018-11-XX

* [add] Add French as a default language in addition to English.
[#962](https://github.com/sharetribe/flex-template-web/pull/962)
* [fix] Show Stripe error message on CheckoutPage if payment request fails because of Stripe error.
Also show error if payment amount is zero.
Also show error if payment amount is zero.
[#960](https://github.com/sharetribe/flex-template-web/pull/960)
* [fix] Remove unused translation keys and update PasswordChangePage title
[#959](https://github.com/sharetribe/flex-template-web/pull/959)
* [fix] Add translations CLI tool [#955](https://github.com/sharetribe/flex-template-web/pull/955)
* [add] Add translations CLI tool [#955](https://github.com/sharetribe/flex-template-web/pull/955)

## [v2.3.2] 2018-11-20

Expand Down
20 changes: 12 additions & 8 deletions docs/translations.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Translations

The Flex template for web supports having a single language for the UI. By default the language is
English.
The Flex Template for Web supports having a single language for the UI. Supported languages are
English and French, English being used by default. For information about changing the language, see
[here](#changing-the-language).

We are using the [React Intl](https://github.com/yahoo/react-intl) library to translate UI texts and
to format dates, numbers, and money values.
Expand Down Expand Up @@ -130,26 +131,29 @@ More information about adding static content to the application can be found fro

## Changing the language

For changing the language of the template application:
If you want the template to use a language that is not supported by default a new translation file
needs to be added and the messages in it need to be translated:

* Copy the default [src/translations/en.json](../src/translations/en.json) English translations file
into some other file like `es.json`.
into some other file, for example `it.json` for Italian.

* Change the messages in the new translations file to the desired language.

Once you have the translations file in place:

* In [src/config.js](../src/config.js), change the `locale` variable value to match the new locale
(the name of the new translations file, without the extension), for example:

```js
const locale = 'es';
const locale = 'it';
```

* In [src/app.js](../src/app.js), change the translation imports to point to the correct
`react-intl` locale and the new translations file you created, for example:

```js
import localeData from 'react-intl/locale-data/es';
import messages from './translations/es.json';
import localeData from 'react-intl/locale-data/it';
import messages from './translations/it.json';
```

Also, in case you will translate the application and develop it forward it is wise to change the
Expand All @@ -159,7 +163,7 @@ in tests. To change the translation file used in tests change the `messages` var
[src/util/test-helpers.js](../src/util/test-helpers.js) to match your language in use, for example:

```js
import messages from '../translations/es.json';
import messages from '../translations/it.json';
```

## Managing translations
Expand Down
Loading