Skip to content

Commit

Permalink
Merge pull request #74 from messerm/messerm/fixI18nKey
Browse files Browse the repository at this point in the history
Fix support for single quotes
  • Loading branch information
cheton authored Feb 28, 2018
2 parents c5e1242 + 4ef36dc commit 7f2b97a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const transformOptions = (options) => {
};

const getStringFromAttribute = (attr) => {
if (attr[0] === '"' || attr[1] === '\'') {
if (attr[0] === '"' || attr[0] === '\'') {
return attr.slice(1, -1);
}
throw new Error('attribute value must be a string');
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/app.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const mycomp = () => (
<React.Fragment>
<Trans i18nKey="key1">Key 1 default</Trans>
<Trans i18nKey='key1SingleQuote'>Key must be key1SingleQuote</Trans>
<Trans i18nKey="key2">
Key 2
default value
Expand Down
2 changes: 2 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ test('Parse Trans component #1', (t) => {
en: {
translation: {
"key1": "Key 1 default",
"key1SingleQuote": "Key must be key1SingleQuote",
"key2": "Key 2 default value",
"key3": "This is a <1>test</1>",
"key4": "You have <1>{{count}}</1> apples",
Expand Down Expand Up @@ -152,6 +153,7 @@ test('Parse Trans component #2', (t) => {
en: {
translation: {
"key1": "Key 1 default",
"key1SingleQuote": "Key must be key1SingleQuote",
"key2": "Key 2 default value",
"key3": "This is a <1>test</1>",
"key4": "You have <1>{{count}}</1> apples",
Expand Down

0 comments on commit 7f2b97a

Please sign in to comment.