@docsector/docsector-reader 0.7.0 → 0.7.2
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/bin/docsector.js +1 -1
- package/package.json +1 -1
- package/src/i18n/helpers.js +50 -0
package/bin/docsector.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsector/docsector-reader",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A documentation rendering engine built with Vue 3, Quasar v2 and Vite. Transform Markdown into beautiful, navigable documentation sites.",
|
|
5
5
|
"productName": "Docsector Reader",
|
|
6
6
|
"author": "Rodrigo de Araujo Vieira",
|
package/src/i18n/helpers.js
CHANGED
|
@@ -16,6 +16,51 @@
|
|
|
16
16
|
* export default buildMessages({ langModules, mdModules, pages, boot })
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Engine default i18n keys, keyed by locale.
|
|
21
|
+
* These are deep-merged into consumer messages so engine components
|
|
22
|
+
* always have their required translations available.
|
|
23
|
+
*/
|
|
24
|
+
const engineDefaults = {
|
|
25
|
+
'en-US': {
|
|
26
|
+
page: {
|
|
27
|
+
lastUpdated: 'Last updated',
|
|
28
|
+
copyPage: 'Copy page',
|
|
29
|
+
copyPageCaption: 'Copy page as Markdown for LLMs',
|
|
30
|
+
copied: 'Copied!',
|
|
31
|
+
viewAsMarkdown: 'View as Markdown',
|
|
32
|
+
viewAsMarkdownCaption: 'View this page as plain text'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
'pt-BR': {
|
|
36
|
+
page: {
|
|
37
|
+
lastUpdated: 'Última atualização',
|
|
38
|
+
copyPage: 'Copiar página',
|
|
39
|
+
copyPageCaption: 'Copiar página como Markdown para LLMs',
|
|
40
|
+
copied: 'Copiado!',
|
|
41
|
+
viewAsMarkdown: 'Ver como Markdown',
|
|
42
|
+
viewAsMarkdownCaption: 'Ver esta página como texto simples'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Deep-merge source into target (target values take precedence).
|
|
49
|
+
*/
|
|
50
|
+
function deepMerge (target, source) {
|
|
51
|
+
for (const key of Object.keys(source)) {
|
|
52
|
+
if (
|
|
53
|
+
source[key] && typeof source[key] === 'object' && !Array.isArray(source[key]) &&
|
|
54
|
+
target[key] && typeof target[key] === 'object' && !Array.isArray(target[key])
|
|
55
|
+
) {
|
|
56
|
+
deepMerge(target[key], source[key])
|
|
57
|
+
} else if (!(key in target)) {
|
|
58
|
+
target[key] = source[key]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return target
|
|
62
|
+
}
|
|
63
|
+
|
|
19
64
|
/**
|
|
20
65
|
* Escape characters that conflict with vue-i18n message syntax.
|
|
21
66
|
*
|
|
@@ -77,6 +122,11 @@ export function buildMessages ({ langModules, mdModules, pages, boot, langs }) {
|
|
|
77
122
|
const langKey = `./languages/${lang}.hjson`
|
|
78
123
|
i18n[lang] = langModules[langKey]?.default || langModules[langKey] || {}
|
|
79
124
|
|
|
125
|
+
// Merge engine defaults (consumer values take precedence)
|
|
126
|
+
if (engineDefaults[lang]) {
|
|
127
|
+
deepMerge(i18n[lang], engineDefaults[lang])
|
|
128
|
+
}
|
|
129
|
+
|
|
80
130
|
// @ Iterate pages
|
|
81
131
|
for (const [key, page] of Object.entries(pages)) {
|
|
82
132
|
const path = key.slice(1)
|