-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
433 additions
and
146 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-disable babel/quotes, react/prop-types, react/jsx-curly-brace-presence */ | ||
|
||
import React from 'react'; | ||
import {makeComponents, Singular, Plural, Param} from '../src/client'; | ||
const {Translate, PluralTranslate} = makeComponents(); | ||
|
||
// i18n: foo comment 1 | ||
Translate.string('foo'); | ||
// i18n: plural foo comment 1 | ||
PluralTranslate.string('foo', 'foos', 42); | ||
|
||
// i18n: foo comment 2 | ||
Translate.string('foo'); | ||
// i18n: plural foo comment 2 | ||
PluralTranslate.string('foo', 'foos', 42); | ||
|
||
/* i18n: multiline | ||
comment | ||
*/ | ||
Translate.string('multiline'); | ||
|
||
/* i18n: multiline | ||
* comment with leading asterisks | ||
*/ | ||
Translate.string('multiline'); | ||
|
||
// No 'i18n:' prefix, should not be extracted | ||
Translate.string('foo'); | ||
|
||
// i18n: Space between the comment and the 'Translate' call, this should not be extracted | ||
|
||
Translate.string('foo'); | ||
|
||
// i18n: Both strings | ||
// i18n: should be extracted | ||
Translate.string('bar'); | ||
|
||
/* i18n: multiple | ||
multiline comments | ||
*/ | ||
/* i18n: are not guaranteed to work | ||
because you should not be using this anyway | ||
*/ | ||
Translate.string('bar'); | ||
|
||
// i18n: Only the last comment should be extracted | ||
// some other comment | ||
// i18n: translator comment | ||
Translate.string('baz'); | ||
|
||
export function TestComponent() { | ||
return ( | ||
<div> | ||
{/* i18n: Title */} | ||
<Translate>Hello & World</Translate> | ||
{/* i18n: multiple */} {/* i18n: translator */} | ||
{/* i18n: comments */} | ||
<Translate>foo bar</Translate> | ||
{/* i18n: rat counter */} | ||
<PluralTranslate count={42}> | ||
<Singular> | ||
You have <Param name="count" value={1} /> rat. | ||
</Singular> | ||
<Plural> | ||
You have <Param name="count" value={2} /> rats. | ||
</Plural> | ||
</PluralTranslate> | ||
{/* i18n: xxx comment */} | ||
{Translate.string('xxx')} | ||
{() => { | ||
// i18n: yyy comment | ||
return PluralTranslate.string('yyy', 'yyys', 42); | ||
}} | ||
</div> | ||
); | ||
} |
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,10 @@ | ||
/* eslint-disable babel/quotes, react/prop-types, react/jsx-curly-brace-presence */ | ||
|
||
import {makeComponents} from '../src/client'; | ||
const {Translate, PluralTranslate} = makeComponents(); | ||
|
||
// Keep this call on the same line as the corresponding call in comments1.jsx | ||
// This tests that the comments do not get mixed up when babel loads another file | ||
Translate.string('baz'); | ||
// Same for this call | ||
PluralTranslate.string('baz', 'bazs', 42); |
Oops, something went wrong.