diff --git a/package.json b/package.json
index d32e408..30f0c5d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "i18next-scanner",
- "version": "3.3.0",
+ "version": "4.0.0",
"description": "Scan your code, extract translation keys/values, and merge them into i18n resource files.",
"homepage": "https://github.com/i18next/i18next-scanner",
"author": "Cheton Wu Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
) in translations instead of indexed keys
+ keepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'], // Which nodes are allowed to be kept in translations during defaultValue generation of
+ line 2
+
+ >
+ `)).toBe('<0>line 1
line 2
0>');
});
diff --git a/test/parser.test.js b/test/parser.test.js
index b559b9f..95b0719 100644
--- a/test/parser.test.js
+++ b/test/parser.test.js
@@ -160,8 +160,8 @@ test('Parse Trans components', () => {
expect(parser.get()).toEqual({
en: {
dev: {
- 'Hello <1>World1>, you have <3>{{count}}3> unread message.': 'Hello <1>World1>, you have <3>{{count}}3> unread message.',
- 'Hello <1>World1>, you have <3>{{count}}3> unread message._plural': 'Hello <1>World1>, you have <3>{{count}}3> unread message.'
+ 'Hello World, you have {{count}} unread message.': 'Hello World, you have {{count}} unread message.',
+ 'Hello World, you have {{count}} unread message._plural': 'Hello World, you have {{count}} unread message.'
},
translation: {
// quote style
@@ -169,8 +169,8 @@ test('Parse Trans components', () => {
'jsx-quotes-single': 'Use single quote for the i18nKey attribute',
// plural
- 'plural': 'You have <1>{{count}}1> apples',
- 'plural_plural': 'You have <1>{{count}}1> apples',
+ 'plural': 'You have {{count}} apples',
+ 'plural_plural': 'You have {{count}} apples',
// context
'context': 'A boyfriend',
@@ -178,22 +178,23 @@ test('Parse Trans components', () => {
// i18nKey
'multiline-text-string': 'multiline text string',
- 'string-literal': 'This is a <1>test1>',
- 'object-expression': 'This is a <1><0>{{test}}0>1>',
- 'arithmetic-expression': '2 + 2 = <1>{{result}}1>',
+ 'string-literal': 'This is a test',
+ 'object-expression': 'This is a {{test}}',
+ 'arithmetic-expression': '2 + 2 = {{result}}',
'components': 'Go to <1>Administration > Tools1> to download administrative tools.',
- 'lorem-ipsum': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>',
- 'lorem-ipsum-nested': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>',
+
+ "lorem-ipsum": "
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // fallback key 'Hello, World!': 'Hello, World!', 'multiline text string': 'multiline text string', - 'This is a <1>test1>': 'This is a <1>test1>', - 'This is a <1><0>{{test}}0>1>': 'This is a <1><0>{{test}}0>1>', - '2 + 2 = <1>{{result}}1>': '2 + 2 = <1>{{result}}1>', + 'This is a test': 'This is a test', + 'This is a {{test}}': 'This is a {{test}}', + '2 + 2 = {{result}}': '2 + 2 = {{result}}', 'Go to <1>Administration > Tools1> to download administrative tools.': 'Go to <1>Administration > Tools1> to download administrative tools.', - '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', - 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', + "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", + "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // defaults 'The component might be self-closing': 'The component might be self-closing', @@ -233,8 +234,8 @@ test('Parse Trans components with fallback key', () => { expect(parser.get()).toEqual({ en: { dev: { - '2290678f8f33c49494499fe5e32b4ebd124d9292': 'Hello <1>World1>, you have <3>{{count}}3> unread message.', - '2290678f8f33c49494499fe5e32b4ebd124d9292_plural': 'Hello <1>World1>, you have <3>{{count}}3> unread message.' + "2f9bdac18af14a38ed4c147f8076c70b740c2ca6": "Hello World, you have {{count}} unread message.", + "2f9bdac18af14a38ed4c147f8076c70b740c2ca6_plural": "Hello World, you have {{count}} unread message.", }, translation: { // quote style @@ -242,8 +243,8 @@ test('Parse Trans components with fallback key', () => { 'jsx-quotes-single': 'Use single quote for the i18nKey attribute', // plural - 'plural': 'You have <1>{{count}}1> apples', - 'plural_plural': 'You have <1>{{count}}1> apples', + 'plural': 'You have {{count}} apples', + 'plural_plural': 'You have {{count}} apples', // context 'context': 'A boyfriend', @@ -251,22 +252,22 @@ test('Parse Trans components with fallback key', () => { // i18nKey 'multiline-text-string': 'multiline text string', - 'string-literal': 'This is a <1>test1>', - 'object-expression': 'This is a <1><0>{{test}}0>1>', - 'arithmetic-expression': '2 + 2 = <1>{{result}}1>', + "string-literal": "This is a test", + "object-expression": "This is a {{test}}", + 'arithmetic-expression': '2 + 2 = {{result}}', 'components': 'Go to <1>Administration > Tools1> to download administrative tools.', - 'lorem-ipsum': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', - 'lorem-ipsum-nested': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', + "lorem-ipsum": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", + "lorem-ipsum-nested": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // fallback key '0a0a9f2a6772942557ab5355d76af442f8f65e01': 'Hello, World!', '32876cbad378f3153c900c297ed2efa06243e0e2': 'multiline text string', - 'e4ca61dff6bc759d214e32c4e37c8ae594ca163d': 'This is a <1>test1>', - '0ce90193dd25c93cdc12f25a36d31004a74c63de': 'This is a <1><0>{{test}}0>1>', - '493781e20cd3cfd5b3137963519571c3d97ab383': '2 + 2 = <1>{{result}}1>', + "e2eff612e7754fb3954034c9be7e600a0456b84b": "This is a test", + "453d2d7753427d2693a0c49758dbcfa30cd71834": "This is a {{test}}", + 'd9ad3431d982619e3b7bd34ed248205312e95bff': '2 + 2 = {{result}}', '083eac6b4f73ec317824caaaeea57fba3b83c1d9': 'Go to <1>Administration > Tools1> to download administrative tools.', - '938c04be9e14562b7532a19458fe92b65c6ef941': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', - '9c3ca5d5d8089e96135c8c7c9f42ba34a635fb47': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', + "11a5b6b7b39fc588da3a1a82d77051bc0e80ad71": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", + "99dbaae55f815e76bdd1b375068c5cc734a7c5b4": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // defaults '7551746c2d33a1d0a24658c22821c8700fa58a0d': 'Hello <1>{{planet}}1>!', diff --git a/test/transform-stream.test.js b/test/transform-stream.test.js index cdaf9bb..1c68727 100644 --- a/test/transform-stream.test.js +++ b/test/transform-stream.test.js @@ -185,8 +185,9 @@ test('[Trans Component] fallbackKey', done => { 'jsx-quotes-single': 'Use single quote for the i18nKey attribute', // plural - 'plural': 'You have <1>{{count}}1> apples', - 'plural_plural': 'You have <1>{{count}}1> apples', + "plural": "You have {{count}} apples", + "plural_plural": "You have {{count}} apples", + // context 'context': 'A boyfriend', @@ -194,22 +195,23 @@ test('[Trans Component] fallbackKey', done => { // i18nKey 'multiline-text-string': 'multiline text string', - 'string-literal': 'This is a <1>test1>', - 'object-expression': 'This is a <1><0>{{test}}0>1>', - 'arithmetic-expression': '2 + 2 = <1>{{result}}1>', + 'string-literal': 'This is a test', + "object-expression": "This is a {{test}}", + "arithmetic-expression": "2 + 2 = {{result}}", 'components': 'Go to <1>Administration > Tools1> to download administrative tools.', - 'lorem-ipsum': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', - 'lorem-ipsum-nested': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', + "lorem-ipsum": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", + "lorem-ipsum-nested": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // fallback key 'Hello, World!': 'Hello, World!', 'multiline text string': 'multiline text string', - 'This is a <1>test1>': 'This is a <1>test1>', - 'This is a <1><0>{{test}}0>1>': 'This is a <1><0>{{test}}0>1>', - '2 + 2 = <1>{{result}}1>': '2 + 2 = <1>{{result}}1>', + "This is a test": "This is a test", + "This is a {{test}}": "This is a {{test}}", + "2 + 2 = {{result}}": "2 + 2 = {{result}}", 'Go to <1>Administration > Tools1> to download administrative tools.': 'Go to <1>Administration > Tools1> to download administrative tools.', - '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>': '<0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.0>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', - 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.1>1><2>Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s2>', + + 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s
': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s
', + "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
", // defaults 'The component might be self-closing': 'The component might be self-closing',