mirror of
https://github.com/knadh/listmonk.git
synced 2024-11-10 09:02:36 +08:00
Update inlang.config.js (#1359)
This commit is contained in:
parent
e0cda4b35c
commit
f577522fe1
2 changed files with 15 additions and 30 deletions
|
@ -27,6 +27,8 @@ To customize an existing language or to load a new language, put one or more `.j
|
|||
|
||||
### Using InLang (external service)
|
||||
|
||||
[![translation badge](https://inlang.com/badge?url=github.com/knadh/listmonk)](https://inlang.com/editor/github.com/knadh/listmonk?ref=badge)
|
||||
|
||||
- Visit [https://inlang.com/editor/github.com/knadh/listmonk](https://inlang.com/editor/github.com/knadh/listmonk)
|
||||
- To make changes and push them, you need to log in to GitHub using OAuth and fork the project from the UI.
|
||||
- Translate the text in the input fields on the UI. You can use the filters to see only the necessary translations.
|
||||
|
|
|
@ -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 }),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return {
|
||||
referenceLanguage: 'en',
|
||||
plugins: [pluginJson({
|
||||
pathPattern: './i18n/{language}.json',
|
||||
variableReferencePattern: ["{", "}"]
|
||||
}), standardLintRules()]
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue