-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from lingui/noop
Add i18nMark function for marking strings for extraction
- Loading branch information
Showing
40 changed files
with
412 additions
and
114 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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
- Providers | ||
- [I18nProvider](#i18nprovider) | ||
- [withI18n](#withi18n) | ||
- Helpers | ||
- [i18nMark](#i18nMark) | ||
|
||
|| Example MessageFormat | ||
--- | -- | ||
|
@@ -392,3 +394,30 @@ const LogoutIcon = withI18n()( | |
|
||
Previous version of this component, named `WithI18n` (upper-cased first letter), | ||
is deprecated and will be removed in [email protected] | ||
|
||
### i18nMark | ||
|
||
`i18nMark(source: string)` | ||
|
||
Mark text for translation, but don't translate it immediatelly. In development, the `i18nMark` function is identity, returning the source string. Such string is extracted to message catalog, so it can be referred in `<Trans>` dynamically: | ||
|
||
```jsx | ||
const message = i18nMark('Source string') | ||
|
||
<Trans id={message} /> | ||
// is the same as | ||
<Trans id="Source string" /> | ||
``` | ||
|
||
This is useful for defining translations outside components: | ||
|
||
```jsx | ||
const languages = { | ||
en: i18nMark('English'), | ||
fr: i18nMark('French') | ||
} | ||
|
||
Object.keys(languages).map(language => | ||
<Trans key={language} id={languages[language]} /> | ||
) | ||
``` |
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 |
---|---|---|
|
@@ -3,6 +3,23 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-extract-messages@[email protected]) (2017-09-05) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* Don't raise warnings about translations from variables ([05596ff](https://github.com/lingui/js-lingui/commit/05596ff)) | ||
* Use Array.includes instead of polyfill ([0aa585c](https://github.com/lingui/js-lingui/commit/0aa585c)) | ||
|
||
|
||
### Features | ||
|
||
* Extract message from i18n_mark identity ([93af236](https://github.com/lingui/js-lingui/commit/93af236)) | ||
|
||
|
||
|
||
|
||
<a name="1.0.6"></a> | ||
## [1.0.6](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-extract-messages@[email protected]) (2017-08-28) | ||
|
||
|
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
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ i18n._("{count, plural, one {# book} other {# books}}", { | |
count: count | ||
} | ||
}) | ||
i18n._(message) |
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
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin-lingui-extract-messages/test/fixtures/noop/actual.js
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,6 @@ | ||
import { i18nMark } from 'lingui-i18n' | ||
|
||
const languages = { | ||
en: i18nMark('English'), | ||
cs: i18nMark('Czech') | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-lingui-extract-messages/test/fixtures/noop/expected.js
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,4 @@ | ||
const languages = { | ||
en: 'English', | ||
cs: 'Czech' | ||
}; |
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.3"></a> | ||
## [1.0.3](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-transform-js@[email protected]) (2017-09-05) | ||
|
||
|
||
|
||
|
||
**Note:** Version bump only for package babel-plugin-lingui-transform-js | ||
|
||
<a name="1.0.2"></a> | ||
## [1.0.2](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-transform-js@[email protected]) (2017-08-28) | ||
|
||
|
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ i18n.t` | |
and replace them with one space. | ||
`; | ||
i18n._(message); |
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.6"></a> | ||
## [1.0.6](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-transform-react@[email protected]) (2017-09-05) | ||
|
||
|
||
|
||
|
||
**Note:** Version bump only for package babel-plugin-lingui-transform-react | ||
|
||
<a name="1.0.5"></a> | ||
## [1.0.5](https://github.com/lingui/js-lingui/compare/babel-plugin-lingui-transform-react@[email protected]) (2017-08-28) | ||
|
||
|
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
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.3"></a> | ||
## [1.0.3](https://github.com/lingui/js-lingui/compare/[email protected]@1.0.3) (2017-09-05) | ||
|
||
|
||
|
||
|
||
**Note:** Version bump only for package babel-preset-lingui-js | ||
|
||
<a name="1.0.2"></a> | ||
## [1.0.2](https://github.com/lingui/js-lingui/compare/[email protected]@1.0.2) (2017-08-28) | ||
|
||
|
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 |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
<a name="1.0.5"></a> | ||
## [1.0.5](https://github.com/lingui/js-lingui/compare/[email protected]@1.0.5) (2017-09-05) | ||
|
||
|
||
|
||
|
||
**Note:** Version bump only for package babel-preset-lingui-react | ||
|
||
<a name="1.0.4"></a> | ||
## [1.0.4](https://github.com/lingui/js-lingui/compare/[email protected]@1.0.4) (2017-08-28) | ||
|
||
|
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.