@fiduswriter/frontend 0.1.66 → 0.1.68
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 +7 -0
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +2 -1
- package/dist/app/index.js.map +1 -1
- package/dist/css/document-template-editor/document_template_designer.css +68 -68
- package/dist/css/image-manager/dialog_usermedia.css +41 -41
- package/dist/user/auth/login.d.ts.map +1 -1
- package/dist/user/auth/login.js +2 -1
- package/dist/user/auth/login.js.map +1 -1
- package/dist/user/auth/signup.d.ts +3 -1
- package/dist/user/auth/signup.d.ts.map +1 -1
- package/dist/user/auth/signup.js +30 -1
- package/dist/user/auth/signup.js.map +1 -1
- package/dist/user/auth/social_icons.d.ts +2 -0
- package/dist/user/auth/social_icons.d.ts.map +1 -0
- package/dist/user/auth/social_icons.js +11 -0
- package/dist/user/auth/social_icons.js.map +1 -0
- package/dist/workers/adjust_doc_to_template.d.ts.map +1 -1
- package/dist/workers/adjust_doc_to_template.js +13 -6
- package/dist/workers/adjust_doc_to_template.js.map +1 -1
- package/locale/ar/messages.json +371 -357
- package/locale/bg/messages.json +371 -357
- package/locale/cs/messages.json +371 -357
- package/locale/da/messages.json +371 -357
- package/locale/de/messages.json +371 -357
- package/locale/en/messages.json +371 -357
- package/locale/en_US/messages.json +371 -357
- package/locale/es/messages.json +371 -357
- package/locale/fr/messages.json +371 -357
- package/locale/it/messages.json +371 -357
- package/locale/ja/messages.json +371 -357
- package/locale/ko/messages.json +371 -357
- package/locale/nb/messages.json +371 -357
- package/locale/nl/messages.json +371 -357
- package/locale/pl/messages.json +371 -357
- package/locale/pt_BR/messages.json +371 -357
- package/locale/pt_PT/messages.json +371 -357
- package/locale/ru/messages.json +371 -357
- package/locale/sv/messages.json +371 -357
- package/locale/tr/messages.json +371 -357
- package/locale/zh_Hans/messages.json +371 -357
- package/package.json +4 -4
- package/scripts/extract-i18n-generic.js +182 -139
- package/src/app/index.ts +3 -1
- package/src/user/auth/login.ts +2 -1
- package/src/user/auth/signup.ts +50 -1
- package/src/user/auth/social_icons.ts +10 -0
- package/src/workers/adjust_doc_to_template.ts +18 -12
- package/scripts/extract-fwtoolkit-i18n.js +0 -230
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* extract-fwtoolkit-i18n.js
|
|
5
|
-
*
|
|
6
|
-
* Scans fwtoolkit/src/ for gettext() calls, extracts unique msgids,
|
|
7
|
-
* looks up translations from the Django djangojs.po files, and writes
|
|
8
|
-
* per-language messages.po files into fwtoolkit/locale/.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* node scripts/extract-fwtoolkit-i18n.js <path-to-django-locale> <path-to-fwtoolkit>
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
* node scripts/extract-fwtoolkit-i18n.js \
|
|
15
|
-
* ../../fiduswriter-server-backend/fiduswriter/locale \
|
|
16
|
-
* ../../fwtoolkit
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync } from "node:fs"
|
|
20
|
-
import { join } from "node:path"
|
|
21
|
-
|
|
22
|
-
const djangoLocalePath = process.argv[2]
|
|
23
|
-
const fwtoolkitPath = process.argv[3]
|
|
24
|
-
|
|
25
|
-
if (!djangoLocalePath || !fwtoolkitPath) {
|
|
26
|
-
console.error("Usage: node extract-fwtoolkit-i18n.js <django-locale-dir> <fwtoolkit-dir>")
|
|
27
|
-
process.exit(1)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
// Step 1 — Scan fwtoolkit/src/ for gettext() calls
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
/** Simple regex: matches gettext("...") with optional whitespace.
|
|
35
|
-
* Does NOT handle gettext(msgid_variable) or template literals. */
|
|
36
|
-
const GETTEXT_RE = /gettext\s*\(\s*["']([^"']+)["']\s*\)/g
|
|
37
|
-
|
|
38
|
-
/** @type {Set<string>} */
|
|
39
|
-
const msgids = new Set()
|
|
40
|
-
|
|
41
|
-
function scanDir(dir) {
|
|
42
|
-
if (!existsSync(dir)) return
|
|
43
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
44
|
-
const full = join(dir, entry.name)
|
|
45
|
-
if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")) {
|
|
46
|
-
scanDir(full)
|
|
47
|
-
} else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
|
|
48
|
-
const content = readFileSync(full, "utf8")
|
|
49
|
-
let match
|
|
50
|
-
while ((match = GETTEXT_RE.exec(content)) !== null) {
|
|
51
|
-
msgids.add(match[1])
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log(`Scanning ${fwtoolkitPath}/src/ for gettext() calls...`)
|
|
58
|
-
scanDir(join(fwtoolkitPath, "src"))
|
|
59
|
-
console.log(`Found ${msgids.size} unique msgids.\n`)
|
|
60
|
-
|
|
61
|
-
if (msgids.size === 0) {
|
|
62
|
-
console.log("No gettext() calls found. Exiting.")
|
|
63
|
-
process.exit(0)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
// Step 2 — Look up translations from Django djangojs.po
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
|
|
70
|
-
const languages = readdirSync(djangoLocalePath, { withFileTypes: true })
|
|
71
|
-
.filter((e) => e.isDirectory())
|
|
72
|
-
.map((e) => e.name)
|
|
73
|
-
|
|
74
|
-
console.log(`Looking up translations in ${languages.length} languages...`)
|
|
75
|
-
|
|
76
|
-
let totalTranslated = 0
|
|
77
|
-
|
|
78
|
-
for (const lang of languages) {
|
|
79
|
-
const poFile = join(djangoLocalePath, lang, "LC_MESSAGES", "djangojs.po")
|
|
80
|
-
if (!existsSync(poFile)) continue
|
|
81
|
-
|
|
82
|
-
const poContent = readFileSync(poFile, "utf8")
|
|
83
|
-
|
|
84
|
-
// Build translation map from this language's djangojs.po
|
|
85
|
-
/** @type {Map<string, {msgstr: string, comment: string}>} */
|
|
86
|
-
const translationMap = new Map()
|
|
87
|
-
|
|
88
|
-
let currentMsgid = null
|
|
89
|
-
let currentComment = ""
|
|
90
|
-
for (const line of poContent.split("\n")) {
|
|
91
|
-
const trimmed = line.trim()
|
|
92
|
-
|
|
93
|
-
// Comment lines
|
|
94
|
-
if (trimmed.startsWith("#:")) {
|
|
95
|
-
if (currentMsgid === null) {
|
|
96
|
-
currentComment += line + "\n"
|
|
97
|
-
}
|
|
98
|
-
continue
|
|
99
|
-
}
|
|
100
|
-
if (trimmed.startsWith("#,") || trimmed.startsWith("#.") || trimmed.startsWith("#|")) {
|
|
101
|
-
if (currentMsgid === null) {
|
|
102
|
-
currentComment += line + "\n"
|
|
103
|
-
}
|
|
104
|
-
continue
|
|
105
|
-
}
|
|
106
|
-
if (trimmed.startsWith("#") && !trimmed.startsWith("#:")) {
|
|
107
|
-
continue
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// msgid line
|
|
111
|
-
if (trimmed.startsWith('msgid "')) {
|
|
112
|
-
currentMsgid = unescapePo(trimmed.slice(7, -1))
|
|
113
|
-
continue
|
|
114
|
-
}
|
|
115
|
-
if (trimmed.startsWith('msgid ')) {
|
|
116
|
-
currentMsgid = unescapePo(trimmed.slice(6))
|
|
117
|
-
continue
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// msgstr line — capture translation
|
|
121
|
-
if (trimmed.startsWith('msgstr "') && currentMsgid !== null) {
|
|
122
|
-
const msgstr = unescapePo(trimmed.slice(8, -1))
|
|
123
|
-
if (msgstr) {
|
|
124
|
-
translationMap.set(currentMsgid, {
|
|
125
|
-
msgstr,
|
|
126
|
-
comment: currentComment.trim(),
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
currentMsgid = null
|
|
130
|
-
currentComment = ""
|
|
131
|
-
continue
|
|
132
|
-
}
|
|
133
|
-
if (trimmed.startsWith('msgstr ') && currentMsgid !== null) {
|
|
134
|
-
const msgstr = unescapePo(trimmed.slice(7))
|
|
135
|
-
if (msgstr) {
|
|
136
|
-
translationMap.set(currentMsgid, {
|
|
137
|
-
msgstr,
|
|
138
|
-
comment: currentComment.trim(),
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
currentMsgid = null
|
|
142
|
-
currentComment = ""
|
|
143
|
-
continue
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Plural forms — skip for simplicity (fwtoolkit doesn't use ngettext)
|
|
147
|
-
if (trimmed.startsWith('msgid_plural') || trimmed.startsWith('msgstr[')) {
|
|
148
|
-
currentMsgid = null
|
|
149
|
-
currentComment = ""
|
|
150
|
-
continue
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Continuation of msgid
|
|
154
|
-
if (trimmed.startsWith('"') && currentMsgid !== null) {
|
|
155
|
-
currentMsgid += unescapePo(trimmed.slice(1, -1))
|
|
156
|
-
continue
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Build .po file content
|
|
161
|
-
const entries = []
|
|
162
|
-
for (const msgid of msgids) {
|
|
163
|
-
const translation = translationMap.get(msgid)
|
|
164
|
-
const msgstr = translation ? translation.msgstr : ""
|
|
165
|
-
const comment = translation ? translation.comment : ""
|
|
166
|
-
entries.push({ msgid, msgstr, comment })
|
|
167
|
-
|
|
168
|
-
if (msgstr) totalTranslated++
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Sort by msgid for stable output
|
|
172
|
-
entries.sort((a, b) => a.msgid.localeCompare(b.msgid))
|
|
173
|
-
|
|
174
|
-
const header = [
|
|
175
|
-
`# Translations for fwtoolkit`,
|
|
176
|
-
`# Language: ${lang}`,
|
|
177
|
-
`# Auto-generated by extract-fwtoolkit-i18n.js`,
|
|
178
|
-
`# Source: fwtoolkit/src/ (gettext() calls)`,
|
|
179
|
-
`#`,
|
|
180
|
-
`msgid ""`,
|
|
181
|
-
`msgstr ""`,
|
|
182
|
-
`"Content-Type: text/plain; charset=UTF-8\\n"`,
|
|
183
|
-
`"Language: ${lang}\\n"`,
|
|
184
|
-
`"Plural-Forms: nplurals=2; plural=(n != 1);\\n"`,
|
|
185
|
-
``,
|
|
186
|
-
].join("\n")
|
|
187
|
-
|
|
188
|
-
const body = entries
|
|
189
|
-
.map((e) => {
|
|
190
|
-
let lines = ""
|
|
191
|
-
if (e.comment) lines += e.comment + "\n"
|
|
192
|
-
lines += `msgid "${escapePo(e.msgid)}"\n`
|
|
193
|
-
lines += `msgstr "${escapePo(e.msgstr)}"\n`
|
|
194
|
-
return lines + "\n"
|
|
195
|
-
})
|
|
196
|
-
.join("")
|
|
197
|
-
|
|
198
|
-
const langDir = join(fwtoolkitPath, "locale", lang, "LC_MESSAGES")
|
|
199
|
-
mkdirSync(langDir, { recursive: true })
|
|
200
|
-
const outFile = join(langDir, "messages.po")
|
|
201
|
-
writeFileSync(outFile, header + body, "utf8")
|
|
202
|
-
|
|
203
|
-
const translated = entries.filter((e) => e.msgstr).length
|
|
204
|
-
console.log(` ${lang}: ${entries.length} entries, ${translated} translated`)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
console.log(`\nTotal translated strings across all languages: ${totalTranslated}`)
|
|
208
|
-
console.log("Done.")
|
|
209
|
-
|
|
210
|
-
// ---------------------------------------------------------------------------
|
|
211
|
-
// Helpers
|
|
212
|
-
// ---------------------------------------------------------------------------
|
|
213
|
-
|
|
214
|
-
function escapePo(s) {
|
|
215
|
-
return s
|
|
216
|
-
.replace(/\\/g, "\\\\")
|
|
217
|
-
.replace(/"/g, '\\"')
|
|
218
|
-
.replace(/\n/g, "\\n")
|
|
219
|
-
.replace(/\r/g, "\\r")
|
|
220
|
-
.replace(/\t/g, "\\t")
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function unescapePo(s) {
|
|
224
|
-
return s
|
|
225
|
-
.replace(/\\"/g, '"')
|
|
226
|
-
.replace(/\\n/g, "\n")
|
|
227
|
-
.replace(/\\r/g, "\r")
|
|
228
|
-
.replace(/\\t/g, "\t")
|
|
229
|
-
.replace(/\\\\/g, "\\")
|
|
230
|
-
}
|