Update inlang.config.js (#1359)

This commit is contained in:
Nils Jacobsen 2023-06-03 14:52:13 +02:00 committed by GitHub
parent e0cda4b35c
commit f577522fe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 30 deletions

View file

@ -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.

View file

@ -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()]
};
}