Skip to content
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

feat: Skip fully filled translations for translate cmd #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/commands/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function* untranslatedStream(translations: Translations): any {
const context = translations[contextKey];
for (const msgid of Object.keys(context)) {
const msg = context[msgid];
msg.msgstr = yield [contextKey, msg];
if (msg.msgstr.includes("") || !msgid) {
msg.msgstr = yield [contextKey, msg];
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/commands/__snapshots__/test_translate.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,18 @@ msgid \\"test_plural\\"
msgid_plural \\"test_plural\\"
msgstr[0] \\"test1\\"
msgstr[1] \\"test2\\"

msgid \\"filled_test\\"
msgstr \\"filled value\\"

msgid \\"partially_filled_test_plural\\"
msgid_plural \\"test_plural\\"
msgstr[0] \\"overwritten test1\\"
msgstr[1] \\"overwritten test2\\"

msgid \\"fully_filled_test_plural\\"
msgid_plural \\"test_plural\\"
msgstr[0] \\"filled value\\"
msgstr[1] \\"filled values\\"
"
`;
1 change: 1 addition & 0 deletions tests/commands/test_translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test("translate poFile", () => {
stream.next("");
stream.next(["test"]);
stream.next(["test1", "test2"]);
stream.next(["overwritten test1", "overwritten test2"]);
const data = serialize(poData).toString();
expect(data).toMatchSnapshot();
});
13 changes: 13 additions & 0 deletions tests/fixtures/translateTest/translate.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ msgid "test_plural"
msgid_plural "test_plural"
msgstr[0] ""
msgstr[1] ""

msgid "filled_test"
msgstr "filled value"

msgid "partially_filled_test_plural"
msgid_plural "test_plural"
msgstr[0] "filled value"
msgstr[1] ""

msgid "fully_filled_test_plural"
msgid_plural "test_plural"
msgstr[0] "filled value"
msgstr[1] "filled values"