@fiduswriter/frontend 0.1.67 → 0.1.69
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/css/two_factor.css +0 -52
- package/css/user_template_manager.css +6 -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/bibliography/colors.css +0 -4
- package/dist/css/bibliography/forms.css +3 -61
- package/dist/css/document-template-editor/document_template_designer.css +68 -68
- package/dist/css/fwtoolkit/action_chooser_dialog.css +66 -0
- package/dist/css/fwtoolkit/action_toolbar.css +132 -0
- package/dist/css/fwtoolkit/alerts.css +53 -19
- package/dist/css/fwtoolkit/application_menu_controller.css +28 -0
- package/dist/css/fwtoolkit/attachment_field.css +19 -0
- package/dist/css/fwtoolkit/attachment_list.css +118 -0
- package/dist/css/fwtoolkit/avatar_label.css +80 -0
- package/dist/css/fwtoolkit/boolean_switch.css +128 -0
- package/dist/css/fwtoolkit/buttons.css +181 -85
- package/dist/css/fwtoolkit/category_filter_controller.css +11 -0
- package/dist/css/fwtoolkit/checkable_list.css +39 -6
- package/dist/css/fwtoolkit/colors.css +71 -69
- package/dist/css/fwtoolkit/common.css +49 -17
- package/dist/css/fwtoolkit/content_menu.css +49 -27
- package/dist/css/fwtoolkit/data_table.css +278 -41
- package/dist/css/fwtoolkit/datatable_bulk.css +106 -0
- package/dist/css/fwtoolkit/destination_settings_form.css +67 -0
- package/dist/css/fwtoolkit/dialog.css +100 -25
- package/dist/css/fwtoolkit/dialog_presets.css +157 -0
- package/dist/css/fwtoolkit/dialog_table.css +63 -26
- package/dist/css/fwtoolkit/directory_navigator.css +244 -0
- package/dist/css/fwtoolkit/drop_up.css +36 -24
- package/dist/css/fwtoolkit/faq_dialog.css +28 -4
- package/dist/css/fwtoolkit/file_input_field.css +150 -0
- package/dist/css/fwtoolkit/file_selector.css +265 -12
- package/dist/css/fwtoolkit/form_error_summary.css +53 -0
- package/dist/css/fwtoolkit/forms.css +261 -54
- package/dist/css/fwtoolkit/fwtoolkit.css +6618 -1522
- package/dist/css/fwtoolkit/grid_size_picker.css +119 -0
- package/dist/css/fwtoolkit/icon_button_group.css +110 -0
- package/dist/css/fwtoolkit/image_preview_field.css +156 -0
- package/dist/css/fwtoolkit/inline_status.css +69 -0
- package/dist/css/fwtoolkit/inline_tools.css +47 -16
- package/dist/css/fwtoolkit/input_list.css +33 -2
- package/dist/css/fwtoolkit/loader.css +12 -2
- package/dist/css/fwtoolkit/media_card_grid.css +251 -0
- package/dist/css/fwtoolkit/navigation_drawer.css +172 -0
- package/dist/css/fwtoolkit/one_time_code_field.css +135 -0
- package/dist/css/fwtoolkit/overflow_action_bar.css +28 -0
- package/dist/css/fwtoolkit/overview_menu.css +35 -27
- package/dist/css/fwtoolkit/permission_badge.css +121 -0
- package/dist/css/fwtoolkit/progress_task.css +51 -27
- package/dist/css/fwtoolkit/pulldown.css +50 -22
- package/dist/css/fwtoolkit/pulldown_menu.css +22 -11
- package/dist/css/fwtoolkit/remote_options_field.css +297 -0
- package/dist/css/fwtoolkit/reset.css +4 -3
- package/dist/css/fwtoolkit/resource_field.css +134 -0
- package/dist/css/fwtoolkit/sortable_list.css +160 -0
- package/dist/css/fwtoolkit/text.css +54 -15
- package/dist/css/fwtoolkit/token_input.css +189 -0
- package/dist/css/fwtoolkit/tokens.css +158 -0
- package/dist/css/fwtoolkit/tree_view.css +165 -0
- package/dist/css/fwtoolkit/two_pane_selector.css +150 -9
- package/dist/css/fwtoolkit/ui_tabs.css +41 -13
- package/dist/css/image-manager/dialog_usermedia.css +41 -41
- package/dist/css/manifest.json +29 -0
- package/dist/css/two_factor.css +0 -52
- package/dist/css/user_template_manager.css +6 -0
- package/dist/document_templates/editor.d.ts +3 -0
- package/dist/document_templates/editor.d.ts.map +1 -1
- package/dist/document_templates/editor.js +35 -18
- package/dist/document_templates/editor.js.map +1 -1
- 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/user/auth/two_factor.d.ts.map +1 -1
- package/dist/user/auth/two_factor.js +133 -157
- package/dist/user/auth/two_factor.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 +8 -7
- package/scripts/extract-i18n-generic.js +182 -139
- package/src/app/index.ts +3 -1
- package/src/document_templates/editor.ts +41 -21
- 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/user/auth/two_factor.ts +203 -228
- package/scripts/extract-fwtoolkit-i18n.js +0 -230
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiduswriter/frontend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
4
4
|
"description": "Fidus Writer-specific shared utilities and UI chrome",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fiduswriter",
|
|
@@ -210,14 +210,14 @@
|
|
|
210
210
|
"postinstall": "node scripts/aggregate-assets.js"
|
|
211
211
|
},
|
|
212
212
|
"dependencies": {
|
|
213
|
-
"@fiduswriter/bibliography-manager": "^0.1.
|
|
214
|
-
"@fiduswriter/document": "^0.3.
|
|
215
|
-
"@fiduswriter/document-template-editor": "^0.1.
|
|
216
|
-
"@fiduswriter/editor": "^0.2.
|
|
217
|
-
"@fiduswriter/image-manager": "^0.1.
|
|
213
|
+
"@fiduswriter/bibliography-manager": "^0.1.39",
|
|
214
|
+
"@fiduswriter/document": "^0.3.43",
|
|
215
|
+
"@fiduswriter/document-template-editor": "^0.1.24",
|
|
216
|
+
"@fiduswriter/editor": "^0.2.52",
|
|
217
|
+
"@fiduswriter/image-manager": "^0.1.31",
|
|
218
218
|
"downloadjs": "^1.4.7",
|
|
219
219
|
"fast-deep-equal": "^3.1.3",
|
|
220
|
-
"fwtoolkit": "^0.
|
|
220
|
+
"fwtoolkit": "^1.0.0",
|
|
221
221
|
"jszip": "^3.10.1",
|
|
222
222
|
"prosemirror-history": "^1.3.2",
|
|
223
223
|
"prosemirror-keymap": "^1.2.2",
|
|
@@ -252,6 +252,7 @@
|
|
|
252
252
|
"fwtoolkit": [
|
|
253
253
|
"reset.css",
|
|
254
254
|
"colors.css",
|
|
255
|
+
"tokens.css",
|
|
255
256
|
"forms.css",
|
|
256
257
|
"buttons.css",
|
|
257
258
|
"dialog.css",
|
|
@@ -7,13 +7,25 @@
|
|
|
7
7
|
* translations from a Django djangojs.po file (including obsolete #~ entries),
|
|
8
8
|
* and writes per-language messages.po into locale/.
|
|
9
9
|
*
|
|
10
|
+
* Translations already present in the target messages.po files are preserved,
|
|
11
|
+
* so re-running extraction never loses work done by translate_all.py or by
|
|
12
|
+
* human translators. All .po parsing handles msgids and msgstrs wrapped over
|
|
13
|
+
* multiple lines (polib and msgcat wrap long lines when saving) — a naive
|
|
14
|
+
* line-based parser silently drops every translation long enough to wrap.
|
|
15
|
+
*
|
|
10
16
|
* Usage:
|
|
11
17
|
* node scripts/extract-i18n.js <path-to-django-locale>
|
|
12
18
|
*/
|
|
13
19
|
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
import {
|
|
21
|
+
readFileSync,
|
|
22
|
+
writeFileSync,
|
|
23
|
+
mkdirSync,
|
|
24
|
+
readdirSync,
|
|
25
|
+
existsSync
|
|
26
|
+
} from "node:fs"
|
|
27
|
+
import {join, dirname} from "node:path"
|
|
28
|
+
import {fileURLToPath} from "node:url"
|
|
17
29
|
|
|
18
30
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
19
31
|
const root = join(__dirname, "..")
|
|
@@ -30,11 +42,20 @@ const msgids = new Set()
|
|
|
30
42
|
|
|
31
43
|
function scanDir(dir) {
|
|
32
44
|
if (!existsSync(dir)) return
|
|
33
|
-
for (const entry of readdirSync(dir, {
|
|
45
|
+
for (const entry of readdirSync(dir, {withFileTypes: true})) {
|
|
34
46
|
const full = join(dir, entry.name)
|
|
35
|
-
if (
|
|
47
|
+
if (
|
|
48
|
+
entry.isDirectory() &&
|
|
49
|
+
entry.name !== "node_modules" &&
|
|
50
|
+
!entry.name.startsWith(".")
|
|
51
|
+
) {
|
|
36
52
|
scanDir(full)
|
|
37
|
-
} else if (
|
|
53
|
+
} else if (
|
|
54
|
+
entry.isFile() &&
|
|
55
|
+
(entry.name.endsWith(".ts") ||
|
|
56
|
+
entry.name.endsWith(".js") ||
|
|
57
|
+
entry.name.endsWith(".mjs"))
|
|
58
|
+
) {
|
|
38
59
|
const content = readFileSync(full, "utf8")
|
|
39
60
|
let match
|
|
40
61
|
while ((match = GETTEXT_RE.exec(content)) !== null) {
|
|
@@ -53,183 +74,185 @@ if (msgids.size === 0) {
|
|
|
53
74
|
process.exit(0)
|
|
54
75
|
}
|
|
55
76
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Parse the active (non-obsolete) entries of a .po file into a Map of
|
|
79
|
+
* msgid → {msgstr, comment}. Handles msgids and msgstrs wrapped over
|
|
80
|
+
* multiple lines. Entries with an empty msgstr and plural entries are
|
|
81
|
+
* skipped.
|
|
82
|
+
*/
|
|
83
|
+
function parsePoEntries(content) {
|
|
84
|
+
const entries = new Map()
|
|
85
|
+
let msgid = null
|
|
86
|
+
let msgstr = ""
|
|
87
|
+
let comment = ""
|
|
88
|
+
let pendingComment = ""
|
|
89
|
+
let mode = null // null | "msgid" | "msgstr"
|
|
68
90
|
|
|
69
|
-
const
|
|
70
|
-
|
|
91
|
+
const flush = () => {
|
|
92
|
+
if (msgid && msgstr) {
|
|
93
|
+
entries.set(msgid, {msgstr, comment: comment.trim()})
|
|
94
|
+
}
|
|
95
|
+
msgid = null
|
|
96
|
+
msgstr = ""
|
|
97
|
+
comment = ""
|
|
98
|
+
mode = null
|
|
99
|
+
}
|
|
71
100
|
|
|
72
|
-
|
|
73
|
-
let currentMsgid = null
|
|
74
|
-
let currentComment = ""
|
|
75
|
-
for (const line of poContent.split("\n")) {
|
|
101
|
+
for (const line of content.split("\n")) {
|
|
76
102
|
const trimmed = line.trim()
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (trimmed.startsWith("#:")) {
|
|
81
|
-
if (currentMsgid === null) currentComment += line + "\n"
|
|
103
|
+
if (trimmed === "") {
|
|
104
|
+
flush()
|
|
105
|
+
pendingComment = ""
|
|
82
106
|
continue
|
|
83
107
|
}
|
|
84
|
-
if (trimmed.startsWith("
|
|
85
|
-
|
|
108
|
+
if (trimmed.startsWith("#~")) {
|
|
109
|
+
// Obsolete entries are handled by parseObsoleteEntries().
|
|
86
110
|
continue
|
|
87
111
|
}
|
|
88
|
-
if (trimmed.startsWith("#")
|
|
89
|
-
|
|
90
|
-
currentMsgid = unescapePo(trimmed.slice(7, -1))
|
|
112
|
+
if (trimmed.startsWith("#")) {
|
|
113
|
+
if (msgid === null) pendingComment += line + "\n"
|
|
91
114
|
continue
|
|
92
115
|
}
|
|
93
116
|
if (trimmed.startsWith("msgid ")) {
|
|
94
|
-
|
|
117
|
+
flush()
|
|
118
|
+
comment = pendingComment
|
|
119
|
+
pendingComment = ""
|
|
120
|
+
mode = "msgid"
|
|
121
|
+
msgid = unescapePo(stripQuotes(trimmed.slice(6)))
|
|
95
122
|
continue
|
|
96
123
|
}
|
|
97
|
-
if (trimmed.startsWith(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
currentMsgid = null
|
|
101
|
-
currentComment = ""
|
|
102
|
-
continue
|
|
103
|
-
}
|
|
104
|
-
if (trimmed.startsWith("msgstr ") && currentMsgid !== null) {
|
|
105
|
-
const msgstr = unescapePo(trimmed.slice(7))
|
|
106
|
-
if (msgstr) translationMap.set(currentMsgid, { msgstr, comment: currentComment.trim() })
|
|
107
|
-
currentMsgid = null
|
|
108
|
-
currentComment = ""
|
|
124
|
+
if (trimmed.startsWith("msgid_plural") || trimmed.startsWith("msgstr[")) {
|
|
125
|
+
msgid = null
|
|
126
|
+
mode = null
|
|
109
127
|
continue
|
|
110
128
|
}
|
|
111
|
-
if (trimmed.startsWith("
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
if (trimmed.startsWith("msgstr ")) {
|
|
130
|
+
if (msgid === null) continue
|
|
131
|
+
mode = "msgstr"
|
|
132
|
+
msgstr = unescapePo(stripQuotes(trimmed.slice(7)))
|
|
114
133
|
continue
|
|
115
134
|
}
|
|
116
|
-
if (trimmed.startsWith('"')
|
|
117
|
-
|
|
135
|
+
if (trimmed.startsWith('"')) {
|
|
136
|
+
const fragment = unescapePo(stripQuotes(trimmed))
|
|
137
|
+
if (mode === "msgid") {
|
|
138
|
+
msgid += fragment
|
|
139
|
+
} else if (mode === "msgstr") {
|
|
140
|
+
msgstr += fragment
|
|
141
|
+
}
|
|
118
142
|
}
|
|
119
143
|
}
|
|
144
|
+
flush()
|
|
145
|
+
return entries
|
|
146
|
+
}
|
|
120
147
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Parse the obsolete (#~) entries of a .po file into a Map of
|
|
150
|
+
* msgid → {msgstr, comment}. These often still hold the translation of a
|
|
151
|
+
* string that was reworded slightly, so they seed new msgids as well.
|
|
152
|
+
*/
|
|
153
|
+
function parseObsoleteEntries(content) {
|
|
154
|
+
const entries = new Map()
|
|
155
|
+
let state = null // null | "msgid" | "msgstr"
|
|
156
|
+
let msgid = ""
|
|
157
|
+
let msgstr = ""
|
|
158
|
+
let prevMsgid = null
|
|
127
159
|
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
|
|
160
|
+
const flush = () => {
|
|
161
|
+
if (msgid && msgstr && !entries.has(msgid)) {
|
|
162
|
+
entries.set(msgid, {msgstr, comment: ""})
|
|
131
163
|
}
|
|
132
|
-
if (
|
|
133
|
-
|
|
164
|
+
if (prevMsgid && msgstr && !entries.has(prevMsgid)) {
|
|
165
|
+
entries.set(prevMsgid, {msgstr, comment: ""})
|
|
134
166
|
}
|
|
167
|
+
state = null
|
|
168
|
+
msgid = ""
|
|
169
|
+
msgstr = ""
|
|
170
|
+
prevMsgid = null
|
|
135
171
|
}
|
|
136
172
|
|
|
137
|
-
for (const line of
|
|
173
|
+
for (const line of content.split("\n")) {
|
|
138
174
|
const trimmed = line.trim()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
obsState = "msgid"
|
|
144
|
-
obsMsgid = unescapePo(trimmed.slice(10, -1))
|
|
145
|
-
obsMsgstr = ""
|
|
146
|
-
obsPrevMsgid = null
|
|
175
|
+
if (trimmed.startsWith('#~ msgid "') || trimmed.startsWith("#~ msgid ")) {
|
|
176
|
+
flush()
|
|
177
|
+
state = "msgid"
|
|
178
|
+
msgid = unescapePo(stripQuotes(trimmed.slice(9)))
|
|
147
179
|
continue
|
|
148
180
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
saveObsolete()
|
|
152
|
-
obsState = "msgid"
|
|
153
|
-
obsMsgid = unescapePo(trimmed.slice(9))
|
|
154
|
-
obsMsgstr = ""
|
|
155
|
-
obsPrevMsgid = null
|
|
181
|
+
if (trimmed.startsWith('#~| msgid "') || trimmed.startsWith("#~| msgid ")) {
|
|
182
|
+
prevMsgid = unescapePo(stripQuotes(trimmed.slice(11)))
|
|
156
183
|
continue
|
|
157
184
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
185
|
+
if (
|
|
186
|
+
state === "msgid" &&
|
|
187
|
+
(trimmed.startsWith('#~ msgstr "') || trimmed.startsWith("#~ msgstr "))
|
|
188
|
+
) {
|
|
189
|
+
state = "msgstr"
|
|
190
|
+
msgstr = unescapePo(stripQuotes(trimmed.slice(11)))
|
|
161
191
|
continue
|
|
162
192
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
if (trimmed.startsWith("#~ msgstr ") && obsState === "msgid" && !trimmed.startsWith('#~ msgstr "')) {
|
|
171
|
-
obsState = "msgstr"
|
|
172
|
-
obsMsgstr = unescapePo(trimmed.slice(10))
|
|
173
|
-
continue
|
|
174
|
-
}
|
|
175
|
-
// ----------- multi-line continuation -----------
|
|
176
|
-
if (trimmed.startsWith('#~ "') && obsState !== null) {
|
|
177
|
-
const fragment = unescapePo(trimmed.slice(4, -1))
|
|
178
|
-
if (obsState === "msgid") {
|
|
179
|
-
obsMsgid += fragment
|
|
180
|
-
} else if (obsState === "msgstr") {
|
|
181
|
-
obsMsgstr += fragment
|
|
193
|
+
if (trimmed.startsWith('#~ "') && state !== null) {
|
|
194
|
+
const fragment = unescapePo(stripQuotes(trimmed.slice(4)))
|
|
195
|
+
if (state === "msgid") {
|
|
196
|
+
msgid += fragment
|
|
197
|
+
} else {
|
|
198
|
+
msgstr += fragment
|
|
182
199
|
}
|
|
183
200
|
continue
|
|
184
201
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
saveObsolete()
|
|
188
|
-
obsState = null
|
|
189
|
-
obsMsgid = ""
|
|
190
|
-
obsMsgstr = ""
|
|
202
|
+
if (state === "msgstr" && !trimmed.startsWith("#~")) {
|
|
203
|
+
flush()
|
|
191
204
|
}
|
|
192
205
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
flush()
|
|
207
|
+
return entries
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Build translation maps from djangojs.po — including obsolete #~ entries
|
|
211
|
+
const languages = readdirSync(djangoLocalePath, {withFileTypes: true})
|
|
212
|
+
.filter(e => e.isDirectory())
|
|
213
|
+
.map(e => e.name)
|
|
214
|
+
|
|
215
|
+
console.log(
|
|
216
|
+
`Looking up translations in ${languages.length} languages (including obsolete entries)...`
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
let totalTranslated = 0
|
|
220
|
+
|
|
221
|
+
for (const lang of languages) {
|
|
222
|
+
const poFile = join(djangoLocalePath, lang, "LC_MESSAGES", "djangojs.po")
|
|
223
|
+
if (!existsSync(poFile)) continue
|
|
224
|
+
|
|
225
|
+
const poContent = readFileSync(poFile, "utf8")
|
|
226
|
+
const translationMap = parsePoEntries(poContent)
|
|
227
|
+
for (const [key, value] of parseObsoleteEntries(poContent)) {
|
|
228
|
+
if (!translationMap.has(key)) translationMap.set(key, value)
|
|
196
229
|
}
|
|
197
230
|
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
//
|
|
231
|
+
// Merge existing translations from the target .po file so translations
|
|
232
|
+
// added by translate_all.py or manual editing are preserved across
|
|
233
|
+
// re-extractions.
|
|
201
234
|
const existingPo = join(root, "locale", lang, "LC_MESSAGES", "messages.po")
|
|
202
235
|
const existingTranslations = new Map()
|
|
203
236
|
if (existsSync(existingPo)) {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (trimmed.startsWith('msgid "')) {
|
|
209
|
-
curMsgid = unescapePo(trimmed.slice(7, -1))
|
|
210
|
-
continue
|
|
211
|
-
}
|
|
212
|
-
if (trimmed.startsWith('msgstr "') && curMsgid !== null) {
|
|
213
|
-
const ms = unescapePo(trimmed.slice(8, -1))
|
|
214
|
-
if (ms) existingTranslations.set(curMsgid, ms)
|
|
215
|
-
curMsgid = null
|
|
216
|
-
continue
|
|
217
|
-
}
|
|
218
|
-
if (trimmed.startsWith('"') && curMsgid !== null) {
|
|
219
|
-
curMsgid += unescapePo(trimmed.slice(1, -1))
|
|
220
|
-
}
|
|
237
|
+
for (const [key, value] of parsePoEntries(
|
|
238
|
+
readFileSync(existingPo, "utf8")
|
|
239
|
+
)) {
|
|
240
|
+
existingTranslations.set(key, value.msgstr)
|
|
221
241
|
}
|
|
222
242
|
}
|
|
223
243
|
|
|
244
|
+
// Build entries
|
|
224
245
|
const entries = []
|
|
225
246
|
for (const msgid of msgids) {
|
|
226
247
|
// Prefer existing translation over djangojs.po lookup (no synthetic comment)
|
|
227
248
|
const existing = existingTranslations.get(msgid)
|
|
228
|
-
const t = existing
|
|
249
|
+
const t = existing
|
|
250
|
+
? {msgstr: existing, comment: ""}
|
|
251
|
+
: translationMap.get(msgid)
|
|
229
252
|
entries.push({
|
|
230
253
|
msgid,
|
|
231
254
|
msgstr: t ? t.msgstr : "",
|
|
232
|
-
comment: t ? t.comment : ""
|
|
255
|
+
comment: t ? t.comment : ""
|
|
233
256
|
})
|
|
234
257
|
if (t?.msgstr) totalTranslated++
|
|
235
258
|
}
|
|
@@ -245,11 +268,11 @@ for (const lang of languages) {
|
|
|
245
268
|
'"Content-Type: text/plain; charset=UTF-8\\n"',
|
|
246
269
|
`"Language: ${lang}\\n"`,
|
|
247
270
|
'"Plural-Forms: nplurals=2; plural=(n != 1);\\n"',
|
|
248
|
-
""
|
|
271
|
+
""
|
|
249
272
|
].join("\n")
|
|
250
273
|
|
|
251
274
|
const body = entries
|
|
252
|
-
.map(
|
|
275
|
+
.map(e => {
|
|
253
276
|
let lines = ""
|
|
254
277
|
if (e.comment && !e.comment.startsWith("# obsolete")) {
|
|
255
278
|
lines += e.comment + "\n"
|
|
@@ -261,18 +284,38 @@ for (const lang of languages) {
|
|
|
261
284
|
.join("")
|
|
262
285
|
|
|
263
286
|
const langDir = join(root, "locale", lang, "LC_MESSAGES")
|
|
264
|
-
mkdirSync(langDir, {
|
|
287
|
+
mkdirSync(langDir, {recursive: true})
|
|
265
288
|
writeFileSync(join(langDir, "messages.po"), header + body, "utf8")
|
|
266
289
|
|
|
267
|
-
const translated = entries.filter(
|
|
268
|
-
console.log(
|
|
290
|
+
const translated = entries.filter(e => e.msgstr).length
|
|
291
|
+
console.log(
|
|
292
|
+
` ${lang}: ${entries.length} entries, ${translated} translated`
|
|
293
|
+
)
|
|
269
294
|
}
|
|
270
295
|
|
|
271
296
|
console.log(`\nTotal translated strings: ${totalTranslated}`)
|
|
272
297
|
|
|
273
298
|
function escapePo(s) {
|
|
274
|
-
return s
|
|
299
|
+
return s
|
|
300
|
+
.replace(/\\/g, "\\\\")
|
|
301
|
+
.replace(/"/g, '\\"')
|
|
302
|
+
.replace(/\n/g, "\\n")
|
|
303
|
+
.replace(/\r/g, "\\r")
|
|
304
|
+
.replace(/\t/g, "\\t")
|
|
275
305
|
}
|
|
306
|
+
|
|
276
307
|
function unescapePo(s) {
|
|
277
|
-
return s
|
|
308
|
+
return s
|
|
309
|
+
.replace(/\\"/g, '"')
|
|
310
|
+
.replace(/\\n/g, "\n")
|
|
311
|
+
.replace(/\\r/g, "\r")
|
|
312
|
+
.replace(/\t/g, "\t")
|
|
313
|
+
.replace(/\\\\/g, "\\")
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function stripQuotes(s) {
|
|
317
|
+
if (s.startsWith('"') && s.endsWith('"') && s.length >= 2) {
|
|
318
|
+
return s.slice(1, -1)
|
|
319
|
+
}
|
|
320
|
+
return s
|
|
278
321
|
}
|
package/src/app/index.ts
CHANGED
|
@@ -210,7 +210,9 @@ export class App {
|
|
|
210
210
|
case "sign-up":
|
|
211
211
|
returnValue = new Signup({
|
|
212
212
|
app: this.config.app as PreloginApp,
|
|
213
|
-
language: this.config.language || ""
|
|
213
|
+
language: this.config.language || "",
|
|
214
|
+
socialaccount_providers:
|
|
215
|
+
this.config.socialaccount_providers ?? []
|
|
214
216
|
})
|
|
215
217
|
break
|
|
216
218
|
default:
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
DocumentTemplateExporter
|
|
5
5
|
} from "@fiduswriter/document-template-editor"
|
|
6
6
|
import {
|
|
7
|
+
ActionToolbar,
|
|
7
8
|
addAlert,
|
|
8
9
|
ensureCSS,
|
|
9
10
|
findTarget,
|
|
@@ -26,6 +27,7 @@ export class DocTemplatesEditor {
|
|
|
26
27
|
template: any
|
|
27
28
|
templateDesigner: any
|
|
28
29
|
dom!: HTMLElement
|
|
30
|
+
private actionToolbar?: ActionToolbar
|
|
29
31
|
|
|
30
32
|
constructor(
|
|
31
33
|
{app, user}: {app: AppLike; user: Record<string, unknown>},
|
|
@@ -73,6 +75,7 @@ export class DocTemplatesEditor {
|
|
|
73
75
|
this.app.apiConnectors.documentTemplate
|
|
74
76
|
)
|
|
75
77
|
this.templateDesigner.init()
|
|
78
|
+
this.initActions()
|
|
76
79
|
this.bind()
|
|
77
80
|
})
|
|
78
81
|
}
|
|
@@ -97,13 +100,8 @@ export class DocTemplatesEditor {
|
|
|
97
100
|
<div class="fw-contents template-editor-wrapper">
|
|
98
101
|
<div id="template-editor"></div>
|
|
99
102
|
<ul class="fw-errorlist"></ul>
|
|
100
|
-
<div class="fw-dialog-buttonset">
|
|
101
|
-
<
|
|
102
|
-
${gettext("Save")}
|
|
103
|
-
</button>
|
|
104
|
-
<button type="button" class="fw-dark fw-button fw-dialog-titlebar-button ui-corner-all ui-widget download">
|
|
105
|
-
${gettext("Download")}
|
|
106
|
-
</button>
|
|
103
|
+
<div class="fw-dialog-buttonset template-editor-actions">
|
|
104
|
+
<div id="template-actions"></div>
|
|
107
105
|
<button type="button" class="fw-orange fw-button fw-dialog-titlebar-button ui-corner-all ui-widget close">
|
|
108
106
|
${gettext("Close")}
|
|
109
107
|
</button>
|
|
@@ -134,12 +132,14 @@ export class DocTemplatesEditor {
|
|
|
134
132
|
this.showErrors(errors)
|
|
135
133
|
return Promise.reject()
|
|
136
134
|
} else {
|
|
137
|
-
return this.app.apiConnectors.documentTemplate
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
return this.app.apiConnectors.documentTemplate
|
|
136
|
+
.save({
|
|
137
|
+
id: this.id,
|
|
138
|
+
value,
|
|
139
|
+
import_id,
|
|
140
|
+
title
|
|
141
|
+
})
|
|
142
|
+
.then(() => addAlert("info", gettext("Saved template")))
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -153,18 +153,38 @@ export class DocTemplatesEditor {
|
|
|
153
153
|
})
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
private initActions(): void {
|
|
157
|
+
const mount = this.dom.querySelector<HTMLElement>("#template-actions")
|
|
158
|
+
if (!mount) {
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
this.actionToolbar = new ActionToolbar({
|
|
162
|
+
label: gettext("Template actions"),
|
|
163
|
+
actions: [
|
|
164
|
+
{
|
|
165
|
+
id: "save",
|
|
166
|
+
label: gettext("Save"),
|
|
167
|
+
onActivate: () => this.save()
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "download",
|
|
171
|
+
label: gettext("Download"),
|
|
172
|
+
onActivate: () => this.download()
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
mount.appendChild(this.actionToolbar.element)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
close(): void {
|
|
180
|
+
this.actionToolbar?.destroy()
|
|
181
|
+
this.actionToolbar = undefined
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
bind(): void {
|
|
157
185
|
this.dom.addEventListener("click", (event: Event) => {
|
|
158
186
|
const el: Record<string, any> = {}
|
|
159
187
|
switch (true) {
|
|
160
|
-
case findTarget(event, "button.save", el):
|
|
161
|
-
event.preventDefault()
|
|
162
|
-
this.save()
|
|
163
|
-
break
|
|
164
|
-
case findTarget(event, "button.download", el):
|
|
165
|
-
event.preventDefault()
|
|
166
|
-
this.download()
|
|
167
|
-
break
|
|
168
188
|
case findTarget(event, "button.close, span.close", el):
|
|
169
189
|
event.preventDefault()
|
|
170
190
|
this.app.goTo("/templates/")
|
package/src/user/auth/login.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {escapeText} from "fwtoolkit"
|
|
2
2
|
import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
|
|
3
|
+
import {socialProviderIcon} from "./social_icons.js"
|
|
3
4
|
|
|
4
5
|
export class LoginPage extends PreloginPage {
|
|
5
6
|
socialaccount_providers: Array<Record<string, unknown>>
|
|
@@ -44,7 +45,7 @@ export class LoginPage extends PreloginPage {
|
|
|
44
45
|
(provider: any) => `<li>
|
|
45
46
|
<a title="${provider.name}" class="fw-button fw-socialaccount fw-${provider.id}"
|
|
46
47
|
href="${provider.login_url}">
|
|
47
|
-
<span class="fab fa-${provider.id}"></span>
|
|
48
|
+
<span class="fab fa-${socialProviderIcon(provider.id)}"></span>
|
|
48
49
|
${gettext("Login with")} ${provider.name}
|
|
49
50
|
</a>
|
|
50
51
|
</li>`
|