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)
|
### 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)
|
- 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.
|
- 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.
|
- 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) {
|
export async function defineConfig(env) {
|
||||||
const plugin = await env.$import(
|
const { default: pluginJson } = await env.$import(
|
||||||
"https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@1/dist/index.js"
|
'https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@2.3.1/dist/index.js'
|
||||||
);
|
);
|
||||||
|
|
||||||
const pluginConfig = {
|
const { default: standardLintRules } = await env.$import(
|
||||||
pathPattern: "./i18n/{language}.json",
|
'https://cdn.jsdelivr.net/gh/inlang/standard-lint-rules@2/dist/index.js'
|
||||||
};
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
referenceLanguage: "en",
|
referenceLanguage: 'en',
|
||||||
languages: await getLanguages(env),
|
plugins: [pluginJson({
|
||||||
readResources: (args) =>
|
pathPattern: './i18n/{language}.json',
|
||||||
plugin.readResources({ ...args, ...env, pluginConfig }),
|
variableReferencePattern: ["{", "}"]
|
||||||
writeResources: (args) =>
|
}), standardLintRules()]
|
||||||
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;
|
|
||||||
}
|
|
Loading…
Reference in a new issue