-
-
Notifications
You must be signed in to change notification settings - Fork 4
fix: nested array of objects #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,16 +80,22 @@ export default function (input, { | |
| } | ||
| appendTo[appendKey] = kv | ||
| } else if (Array.isArray(value)) { | ||
| kv = { | ||
| if (value.every(v => typeof v === 'string')) { | ||
| kv = { | ||
| // id: key.replace(new RegExp(' ', 'g'), ''), | ||
| key, | ||
| value: value.join('\n'), | ||
| isArray: true, | ||
| isPlural, | ||
| pluralNumber: isPlural ? number : 0, | ||
| context | ||
| key, | ||
| value: value.join('\n'), | ||
|
Comment on lines
82
to
+87
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied the same "array of strings" guard in |
||
| isArray: true, | ||
| isPlural, | ||
| pluralNumber: isPlural ? number : 0, | ||
| context | ||
| } | ||
| appendTo[appendKey] = kv | ||
| } else { | ||
| value.forEach((v, i) => { | ||
| recurse(appendTo, v, `${key}${keyseparator}${i}`) | ||
| }) | ||
|
Comment on lines
+95
to
+97
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot apply changes based on this feedback
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests were already added in commit 9f4f02f: |
||
| } | ||
| appendTo[appendKey] = kv | ||
| } else { | ||
| recurse(appendTo, value, key) | ||
| } | ||
|
|
@@ -174,16 +180,22 @@ export default function (input, { | |
| } | ||
| appendTo[appendKey] = kv | ||
| } else if (Array.isArray(value)) { | ||
| kv = { | ||
| // id: key.replace(new RegExp(' ', 'g'), ''), | ||
| key, | ||
| value: value.join('\n'), | ||
| isArray: true, | ||
| isPlural, | ||
| pluralNumber: isPlural ? number : 0, | ||
| context | ||
| if (value.every(v => typeof v === 'string')) { | ||
| kv = { | ||
| // id: key.replace(new RegExp(' ', 'g'), ''), | ||
| key, | ||
| value: value.join('\n'), | ||
| isArray: true, | ||
| isPlural, | ||
| pluralNumber: isPlural ? number : 0, | ||
| context | ||
| } | ||
| appendTo[appendKey] = kv | ||
| } else { | ||
| value.forEach((v, i) => { | ||
| recurse(appendTo, v, `${key}${keyseparator}${i}`) | ||
| }) | ||
| } | ||
| appendTo[appendKey] = kv | ||
| } else { | ||
| recurse(appendTo, value, key) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "parent": { | ||
| "questions": [ | ||
| { | ||
| "title": "test question", | ||
| "answer": "test answer" | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: gettext-converter\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=utf-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1)\n" | ||
| "POT-Creation-Date: 2020-04-17T10:46:16.313Z\n" | ||
| "PO-Revision-Date: 2020-04-17T10:46:16.313Z\n" | ||
| "Language: en-US\n" | ||
|
|
||
| msgid "parent##questions##0##title" | ||
| msgstr "test question" | ||
|
|
||
| msgid "parent##questions##0##answer" | ||
| msgstr "test answer" |
Uh oh!
There was an error while loading. Please reload this page.