@riebeckite/plugin-l10n 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/README_ja.md +13 -1
- package/dist/index.js +7 -1
- package/dist/src/l10n.d.ts +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ translation: getting-started
|
|
|
30
30
|
---
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Conventions may be mixed. Built-in precedence is **frontmatter > custom detector > filename > default language**. Conflicts emit `L10N_LANGUAGE_CONFLICT`; use `strict: true` to fail the build instead. A duplicate
|
|
33
|
+
Conventions may be mixed. Built-in precedence is **frontmatter > custom detector > filename > default language**. Conflicts emit `L10N_LANGUAGE_CONFLICT`; use `strict: true` to fail the build instead. A duplicate translation identity and language emits `L10N_DUPLICATE_TRANSLATION` (and also fails in strict mode).
|
|
34
34
|
|
|
35
35
|
`translation` is independent of locale and filename. Use it to group files with unrelated paths or names:
|
|
36
36
|
|
|
@@ -39,6 +39,18 @@ Conventions may be mixed. Built-in precedence is **frontmatter > custom detector
|
|
|
39
39
|
English/getting-started.md lang: en, translation: getting-started
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Set `translationKey` to read the identity from a different frontmatter property:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
l10n({
|
|
46
|
+
defaultLang: "ja",
|
|
47
|
+
languages: ["ja", "en"],
|
|
48
|
+
translationKey: "translationId",
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
With this option, `translationId: getting-started` replaces `translation: getting-started`. The default is `translation`.
|
|
53
|
+
|
|
42
54
|
## URLs and missing translations
|
|
43
55
|
|
|
44
56
|
The default language keeps Core's resolved URL (`/about`); other languages are prefixed (`/en/about`). The plugin augments the existing content-location resolver, so it works with other URL plugins rather than creating a router. Different source paths or a permalink plugin can provide different resolved URLs for translations.
|
package/README_ja.md
CHANGED
|
@@ -27,7 +27,7 @@ translation: getting-started
|
|
|
27
27
|
---
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
組み合わせた場合の組み込み規則の優先順位は **frontmatter > 独自検出 > ファイル名 > 既定言語** です。矛盾は `L10N_LANGUAGE_CONFLICT
|
|
30
|
+
組み合わせた場合の組み込み規則の優先順位は **frontmatter > 独自検出 > ファイル名 > 既定言語** です。矛盾は `L10N_LANGUAGE_CONFLICT`、同一の翻訳 ID と言語の重複は `L10N_DUPLICATE_TRANSLATION` として診断します。`strict: true` ではビルドを失敗させます。
|
|
31
31
|
|
|
32
32
|
`translation` はロケール検出とは別です。異なるパス・ファイル名でも明示的な ID でグループ化できます。
|
|
33
33
|
|
|
@@ -36,6 +36,18 @@ translation: getting-started
|
|
|
36
36
|
English/getting-started.md lang: en, translation: getting-started
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
翻訳グループの ID を読み取る frontmatter プロパティは `translationKey` で変更できます。
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
l10n({
|
|
43
|
+
defaultLang: "ja",
|
|
44
|
+
languages: ["ja", "en"],
|
|
45
|
+
translationKey: "translationId",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
この場合、`translation: getting-started` の代わりに `translationId: getting-started` を使用します。既定値は `translation` です。
|
|
50
|
+
|
|
39
51
|
翻訳がない言語のページを複製・生成することはありません。`getLocalization(manifest, slug)` は存在する翻訳だけを `availableLanguages` と言語ごとの `translations` に含め、`getLocalizedContent(manifest, slug, lang)` は見つからなければ `null` を返します。
|
|
40
52
|
|
|
41
53
|
## URL・テーマ・SEO
|
package/dist/index.js
CHANGED
|
@@ -163,6 +163,7 @@ function resolveOptions(options) {
|
|
|
163
163
|
languages.map((language) => [language.toLowerCase(), language])
|
|
164
164
|
),
|
|
165
165
|
strict: options.strict ?? false,
|
|
166
|
+
translationKey: (options.translationKey ?? "translation").trim(),
|
|
166
167
|
detect: options.detect
|
|
167
168
|
};
|
|
168
169
|
}
|
|
@@ -195,6 +196,9 @@ function validateOptions(options) {
|
|
|
195
196
|
if (options.strict !== void 0 && typeof options.strict !== "boolean") {
|
|
196
197
|
errors.push("l10n.strict must be a boolean.");
|
|
197
198
|
}
|
|
199
|
+
if (options.translationKey !== void 0 && (typeof options.translationKey !== "string" || !options.translationKey.trim())) {
|
|
200
|
+
errors.push("l10n.translationKey must be a non-empty string.");
|
|
201
|
+
}
|
|
198
202
|
if (options.detect !== void 0 && typeof options.detect !== "function") {
|
|
199
203
|
errors.push("l10n.detect must be a function.");
|
|
200
204
|
}
|
|
@@ -256,7 +260,9 @@ function detectContents(entries, options) {
|
|
|
256
260
|
diagnostics.push(conflictDiagnostic(entry, signals, options.strict));
|
|
257
261
|
}
|
|
258
262
|
const lang = signals.frontmatter ?? signals.custom ?? signals.filename ?? options.defaultLang;
|
|
259
|
-
const translationId = readTranslationId(
|
|
263
|
+
const translationId = readTranslationId(
|
|
264
|
+
custom?.translationId ?? frontmatter[options.translationKey]
|
|
265
|
+
) ?? deriveTranslationId(entry.path, filenameLanguage);
|
|
260
266
|
const content = {
|
|
261
267
|
path: entry.path,
|
|
262
268
|
slug: entry.slug,
|
package/dist/src/l10n.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-l10n",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"hono": "^4.12.25",
|
|
25
25
|
"yaml": "^2.9.0",
|
|
26
|
-
"@riebeckite/
|
|
27
|
-
"@riebeckite/
|
|
26
|
+
"@riebeckite/ui": "0.0.31",
|
|
27
|
+
"@riebeckite/core": "0.0.31"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"tsx": "^4.22.4",
|
|
31
|
-
"@riebeckite/plugin-obsidian-markdown": "0.0.
|
|
31
|
+
"@riebeckite/plugin-obsidian-markdown": "0.0.31"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|