-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add i18n bootstrap files * add i18n setting * i18n: account view * i18n: auction view * i18n: domain manager, exchange, domain details, get coins, onboarding * i18n: setting, sign, verify, watchlist, yourbids, transactions * i18n: persist setting, splash screen * sort en.json * add instruction * add note to maintainers
- Loading branch information
1 parent
c3f93b1
commit 2d6b9a5
Showing
82 changed files
with
2,345 additions
and
811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Internationalization (i18n) | ||
|
||
This documents describes how i18n works in Bob Wallet, and how to add support for a new language | ||
|
||
## Overview | ||
|
||
All locale strings are saved as `{locale}.json` based on result return from [electron.app.getLocale()](https://source.chromium.org/chromium/chromium/src/+/master:ui/base/l10n/l10n_util.cc). | ||
|
||
A locale json looks like this: | ||
|
||
en.json | ||
```json | ||
{ | ||
"hello": "Hello, %s!" | ||
} | ||
``` | ||
|
||
On app starts, all locale strings are compiled into a JSON object, and injected to the app using [React Context](https://reactjs.org/docs/context.html). | ||
|
||
Usage Example: | ||
```js | ||
import {I18nContext} from "../../utils/i18n"; | ||
|
||
class Example extends Component { | ||
static contextType = I18nContext; | ||
|
||
render() { | ||
const {t} = this.context; | ||
|
||
// This will render "Hello, World!" based on en.json above | ||
return ( | ||
<div>{t('hello', 'World')}</div> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
|
||
When getting string using the injected `this.context.t(localeKey)` function, the app will: | ||
- first check to see if there is a matching string for `localeKey` from the exact locale (e.g. `en-US.json`) | ||
- if a matching string cannot be found, it will check to see if there is matching string for `localeKey` from the root locale (e.g. `en-US.json` -> `en.json`) | ||
- if a match is still not found, it will use `en.json` by default | ||
- if `localeKey` is not found in `en.json`, it will render `this.context.t(localeKey)` in the UI; | ||
|
||
|
||
## Adding Support for New Language | ||
|
||
1. Copy `/locales/en.json` to a new file, and save it as `[locale].json`. For example, if you are adding support for Spanish, the file name should be `es.json`. You can find all valid locale strings [here](https://source.chromium.org/chromium/chromium/src/+/master:ui/base/l10n/l10n_util.cc). | ||
2. Start translating 📙 | ||
3. When finished translating, save your file | ||
4. Go to https://github.com/kyokan/bob-wallet/tree/master/locales | ||
5. Click `Add Files -> Uplaod Files` | ||
6. Drag and drop your file to upload it to GitHub | ||
7. Make sure you select **Create a new branch for this commit and start a pull request.** | ||
8. Click **Propose Change** | ||
|
||
## Note to Maintainers | ||
|
||
When merging in a new locale json, be sure to update the dropdown list in `app/util/i18n.js` with the new locale. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
@extend %row-nowrap; | ||
flex: 1 1 auto; | ||
width: 0; | ||
text-transform: capitalize; | ||
} | ||
|
||
&__toggle { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import React, { Component } from 'react'; | ||
import ConnectLedgerStep from './index'; | ||
import {I18nContext} from "../../utils/i18n"; | ||
|
||
export default class DefaultConnectLedgerSteps extends Component { | ||
static contextType = I18nContext; | ||
|
||
render() { | ||
const {completedSteps} = this.props; | ||
const {t} = this.props; | ||
|
||
return ( | ||
<React.Fragment> | ||
<ConnectLedgerStep | ||
stepNumber={1} | ||
stepDescription={t('obLedgerStep1')} | ||
stepCompleted={completedSteps[0]} | ||
/> | ||
<ConnectLedgerStep | ||
stepNumber={2} | ||
stepDescription={t('obLedgerStep2')} | ||
stepCompleted={completedSteps[1]} | ||
/> | ||
<ConnectLedgerStep | ||
stepNumber={3} | ||
stepDescription={t('obLedgerStep3')} | ||
stepCompleted={completedSteps[2]} | ||
/> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
export default function DefaultConnectLedgerSteps(props) { | ||
return ( | ||
<React.Fragment> | ||
<ConnectLedgerStep | ||
stepNumber={1} | ||
stepDescription="Connect your Ledger directly to your computer." | ||
stepCompleted={props.completedSteps[0]} | ||
/> | ||
<ConnectLedgerStep | ||
stepNumber={2} | ||
stepDescription="Enter your secret pin on your Ledger device." | ||
stepCompleted={props.completedSteps[1]} | ||
/> | ||
<ConnectLedgerStep | ||
stepNumber={3} | ||
stepDescription="Select the Handshake app on your Ledger." | ||
stepCompleted={props.completedSteps[2]} | ||
/> | ||
</React.Fragment> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.