Skip to content

Commit

Permalink
Merge pull request #6 from jannesblobel/showing_refLanguage_in_editor
Browse files Browse the repository at this point in the history
Showing_refLanguage_in_editor
Remove the filter for the reference languages
  • Loading branch information
jannesblobel authored May 18, 2023
2 parents 577e6e1 + ba94b55 commit 11c4d93
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
16 changes: 8 additions & 8 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions example/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ msgstr "übersetze mich automatisch"
msgid "0.3 or older"
msgstr "0,3 oder älter"

msgid "new-message"
msgstr "Newly created message"

1 change: 1 addition & 0 deletions example/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ msgstr ""
msgid "0.3 or older"
msgstr ""

#. test comment
msgid "test"
msgstr "This message is used for testing purposes."

Expand Down
8 changes: 5 additions & 3 deletions example/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.4\n"

#. test comment
msgid "test"
msgstr "This message is used for testing purposes."

#: conf.py:17
msgid "date"
msgstr "Datum"

#. test comment
msgid "test"
msgstr "This message is used for testing purposes."


#: conf.py:18
msgid "year"
Expand Down
6 changes: 3 additions & 3 deletions inlang.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export async function defineConfig(env) {
const plugin = await env.$import("../dist/index.js");

const pluginConfig = {
pathPattern: "./example/locale/{language}/LC_MESSAGES/django.po",
// pathPattern: "./example/{language}.po",
// pathPattern: "./example/locale/{language}/LC_MESSAGES/django.po",
pathPattern: "./example/{language}.po",

// Your referenceResourcePath could be
// null or "./example/locale/en/LC_MESSAGES/django.pot",
// dependent if you use pot file as you referenceLanguage
referenceResourcePath: null,
referenceResourcePath: "./example/en.pot",
};

return {
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export async function getLanguages(
}
}
}

return languages;
}
/**
Expand Down Expand Up @@ -101,7 +100,6 @@ export async function readResources(
const poFile = gettextParser.po.parse(
(await args.$fs.readFile(resourcePath, "utf-8")) as string
);

resources.push(parseResource(poFile, language));
}

Expand Down Expand Up @@ -158,14 +156,16 @@ export async function writeResources(
EnvironmentFunctions & { pluginConfig: PluginConfig }
): ReturnType<Config["writeResources"]> {
for (const resource of args.resources) {
// ?? This line avoid the write on a pot file
// Action: prevent the user from rewriting a pot file
// Reason: pot Contains the keys for each msgstr
if (
args.pluginConfig.referenceResourcePath === null &&
resource.languageTag.name === args.config.referenceLanguage
) {
continue;
}
// if (
// args.pluginConfig.referenceResourcePath === null &&
// resource.languageTag.name === args.config.referenceLanguage
// ) {
// continue;
// }

// Action:if a referenceResourcePath is defined, the path differs. Thus, take path from plugin config.
// Reason: referenceResourcePath is defined or null and we need to filter the defineded referenceResourcePath
const resourcePath =
Expand Down

0 comments on commit 11c4d93

Please sign in to comment.