-
Notifications
You must be signed in to change notification settings - Fork 72
Internationalization
All messages are kept in messages
object in src/intl/messages.js
. Message values are in ICU Message format (demo).
Message define as
src/intl/messages.js:
export const messages = {
foo: 'Foo {var}'
}
can be used either programmatically (preferred way)
import { msg } from './intl'
const translated = msg.foo({ var: 'bar' }) // 'Foo bar'
or declaratively
import { FormattedMessage } from 'react-intl'
import { id } from './intl'
const rendered = (<FormattedMessage id={id.foo} values={ var: 'bar' } />) // <span>Foo bar</span>
Please note that <FormattedMessage>
component wraps rendered string in often unnecessary <span>
.
- When the application is loaded and the url contains query parameter
locale
value of which is supported, this locale is used. - If value of
navigator.language
is supported, this locale is used. - If a value of
navigator.language
is supported, this locale is used. en
Web UI uses internationalization libraries from format.js project. intl-messageformat to format messages and react-intl to render strings in React environment.
Messages are translated using Zanata translation platform. Project page. Communication with Zanata platform is done by zanata-cli
client (zanata-client
rpm package). To configure the zanata-cli
one needs to download ~/.config/zanata.ini
from Zanata user settings and zanata.xml
(in root of project, already in git) from project settings.
Threre are 4 yarn scripts dedicated to translations intended to be used in following order:
-
intl:extract
extracts messages toextra/to-zanata
directory into a '.pot' file. -
intl:push
uploads strings to Zanata -
intl:pull
downloads translated strings from Zanata and stores them inextra/from-zanata
directory in form of a '.po' file per language. -
intl:apply
converts.po
files tosrc/intl/translated-messages.json
that are consumed by the application.
zanata-cli push --push-type=trans -l it,ja,fr
can be used to upload selected '.po' files. This is often used when English value is changed.
- Create new version in Zanata by cloning
- Go at https://translate.zanata.org/project/view/ovirt-web-ui/versions.
- Click "..." > "New Version".
- Check "Copy from previous version".
- (optional) Make old version read-only if applicable.
- Go at https://translate.zanata.org/iteration/view/ovirt-web-ui/{old-version-name}/settings
- Click "Make this version read only"
- Update value of
/config/project-version
tag in filezanata.xml
in the repository.
-
yarn run intl:extract
to createextra/to-zanata/messages.pot
-
yarn run intl:pull
to download files from Zanata toextra/from-zanata
directory -
yarn run intl:apply
to updatesrc/intl/messages.js
based on content ofextra/from-zanata
andextra/to-zanata/messages.pot