Skip to content

Commit f577522

Browse files
authoredJun 3, 2023
Update inlang.config.js (knadh#1359)
1 parent e0cda4b commit f577522

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed
 

‎docs/docs/content/i18n.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ To customize an existing language or to load a new language, put one or more `.j
2727

2828
### Using InLang (external service)
2929

30+
[![translation badge](https://inlang.com/badge?url=github.com/knadh/listmonk)](https://inlang.com/editor/github.com/knadh/listmonk?ref=badge)
31+
3032
- Visit [https://inlang.com/editor/github.com/knadh/listmonk](https://inlang.com/editor/github.com/knadh/listmonk)
3133
- To make changes and push them, you need to log in to GitHub using OAuth and fork the project from the UI.
3234
- Translate the text in the input fields on the UI. You can use the filters to see only the necessary translations.

‎inlang.config.js

+13-30
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
1-
/**
2-
* See https://inlang.com/documentation
3-
*/
41
export async function defineConfig(env) {
5-
const plugin = await env.$import(
6-
"https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@1/dist/index.js"
7-
);
2+
const { default: pluginJson } = await env.$import(
3+
'https://cdn.jsdelivr.net/gh/samuelstroschein/inlang-plugin-json@2.3.1/dist/index.js'
4+
);
85

9-
const pluginConfig = {
10-
pathPattern: "./i18n/{language}.json",
11-
};
6+
const { default: standardLintRules } = await env.$import(
7+
'https://cdn.jsdelivr.net/gh/inlang/standard-lint-rules@2/dist/index.js'
8+
);
129

13-
return {
14-
referenceLanguage: "en",
15-
languages: await getLanguages(env),
16-
readResources: (args) =>
17-
plugin.readResources({ ...args, ...env, pluginConfig }),
18-
writeResources: (args) =>
19-
plugin.writeResources({ ...args, ...env, pluginConfig }),
20-
};
10+
return {
11+
referenceLanguage: 'en',
12+
plugins: [pluginJson({
13+
pathPattern: './i18n/{language}.json',
14+
variableReferencePattern: ["{", "}"]
15+
}), standardLintRules()]
16+
};
2117
}
22-
23-
24-
/**
25-
* Automatically derives the languages in this repository.
26-
*/
27-
async function getLanguages(env) {
28-
// replace the path
29-
const files = await env.$fs.readdir("./i18n");
30-
// files that end with .json
31-
// remove the .json extension to only get language name
32-
const languages = files.filter((name) => name.endsWith(".json")).map((name) => name.replace(".json", ""));
33-
return languages;
34-
}

0 commit comments

Comments
 (0)
Please sign in to comment.