forked from knadh/listmonk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update inlang.config.js (knadh#1359)
- Loading branch information
1 parent
e0cda4b
commit f577522
Showing
2 changed files
with
15 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,17 @@ | ||
/** | ||
* See https://inlang.com/documentation | ||
*/ | ||
export async function defineConfig(env) { | ||
const plugin = await env.$import( | ||
"https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@1/dist/index.js" | ||
); | ||
const { default: pluginJson } = await env.$import( | ||
'https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@2.3.1/dist/index.js' | ||
); | ||
|
||
const pluginConfig = { | ||
pathPattern: "./i18n/{language}.json", | ||
}; | ||
const { default: standardLintRules } = await env.$import( | ||
'https://cdn.jsdelivr.net/gh/inlang/standard-lint-rules@2/dist/index.js' | ||
); | ||
|
||
return { | ||
referenceLanguage: "en", | ||
languages: await getLanguages(env), | ||
readResources: (args) => | ||
plugin.readResources({ ...args, ...env, pluginConfig }), | ||
writeResources: (args) => | ||
plugin.writeResources({ ...args, ...env, pluginConfig }), | ||
}; | ||
return { | ||
referenceLanguage: 'en', | ||
plugins: [pluginJson({ | ||
pathPattern: './i18n/{language}.json', | ||
variableReferencePattern: ["{", "}"] | ||
}), standardLintRules()] | ||
}; | ||
} | ||
|
||
|
||
/** | ||
* Automatically derives the languages in this repository. | ||
*/ | ||
async function getLanguages(env) { | ||
// replace the path | ||
const files = await env.$fs.readdir("./i18n"); | ||
// files that end with .json | ||
// remove the .json extension to only get language name | ||
const languages = files.filter((name) => name.endsWith(".json")).map((name) => name.replace(".json", "")); | ||
return languages; | ||
} |