Skip to content

Commit 8ec798e

Browse files
authored
Merge pull request #966 from nextcloud-libraries/fix/l10n
[stable4] fix(l10n): Extract translations also from vue SFC template attributes
2 parents 91e90a6 + c0ae6f2 commit 8ec798e

File tree

2 files changed

+68
-47
lines changed

2 files changed

+68
-47
lines changed

build/extract-l10n.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
import { GettextExtractor, JsExtractors } from 'gettext-extractor'
1+
import { GettextExtractor, JsExtractors, HtmlExtractors } from 'gettext-extractor'
22

3-
let extractor = new GettextExtractor();
3+
const extractor = new GettextExtractor()
44

5-
extractor
6-
.createJsParser([
7-
JsExtractors.callExpression('t', {
8-
arguments: {
9-
text: 0,
10-
}
11-
}),
12-
JsExtractors.callExpression('n', {
13-
arguments: {
14-
text: 1,
15-
textPlural: 2,
16-
}
17-
}),
18-
])
19-
.parseFilesGlob('./lib/**/*.@(ts|js|vue)');
5+
const jsParser = extractor.createJsParser([
6+
JsExtractors.callExpression('t', {
7+
arguments: {
8+
text: 0,
9+
},
10+
}),
11+
JsExtractors.callExpression('n', {
12+
arguments: {
13+
text: 0,
14+
textPlural: 1,
15+
},
16+
}),
17+
])
18+
.parseFilesGlob('./lib/**/*.@(ts|js)')
2019

21-
extractor.savePotFile('./l10n/messages.pot');
20+
extractor.createHtmlParser([
21+
HtmlExtractors.embeddedJs('*', jsParser),
22+
HtmlExtractors.embeddedAttributeJs(/:[a-z]+/, jsParser),
23+
])
24+
.parseFilesGlob('./lib/**/*.vue')
2225

23-
extractor.printStats();
26+
// remove references to avoid conflicts
27+
extractor.getMessages().forEach((msg) => {
28+
msg.references = []
29+
})
30+
31+
extractor.savePotFile('./l10n/messages.pot')
32+
33+
extractor.printStats()

l10n/messages.pot

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,110 +2,121 @@ msgid ""
22
msgstr ""
33
"Content-Type: text/plain; charset=UTF-8\n"
44

5-
#: lib/components/FilePicker/FilePickerBreadcrumbs.vue:91
65
msgid "\"{name}\" is an invalid file name."
76
msgstr ""
87

9-
#: lib/components/FilePicker/FilePickerBreadcrumbs.vue:93
108
msgid "\"{name}\" is not an allowed filetype"
119
msgstr ""
1210

13-
#: lib/components/FilePicker/FilePickerBreadcrumbs.vue:89
1411
msgid "\"/\" is not allowed inside a file name."
1512
msgstr ""
1613

17-
#: lib/components/FilePicker/NcDatetime.vue:34
1814
msgid "a few seconds ago"
1915
msgstr ""
2016

21-
#: lib/components/FilePicker/FilePickerNavigation.vue:57
2217
msgid "All files"
2318
msgstr ""
2419

25-
#: lib/legacy.ts:155
2620
msgid "Choose"
2721
msgstr ""
2822

29-
#: lib/legacy.ts:155
3023
msgid "Choose {file}"
3124
msgstr ""
3225

33-
#: lib/legacy.ts:163
3426
msgid "Copy"
3527
msgstr ""
3628

37-
#: lib/legacy.ts:163
3829
msgid "Copy to {target}"
3930
msgstr ""
4031

41-
#: lib/components/FilePicker/FilePicker.vue:252
4232
msgid "Could not create the new folder"
4333
msgstr ""
4434

45-
#: lib/components/FilePicker/FilePicker.vue:160
46-
#: lib/components/FilePicker/FilePickerNavigation.vue:65
35+
msgid "Create directory"
36+
msgstr ""
37+
38+
msgid "Current view selector"
39+
msgstr ""
40+
4741
msgid "Favorites"
4842
msgstr ""
4943

50-
#: lib/components/FilePicker/FilePickerBreadcrumbs.vue:87
5144
msgid "File name cannot be empty."
5245
msgstr ""
5346

54-
#: lib/components/FilePicker/FilePicker.vue:238
47+
msgid "Filepicker sections"
48+
msgstr ""
49+
5550
msgid "Files and folders you mark as favorite will show up here."
5651
msgstr ""
5752

58-
#: lib/components/FilePicker/FilePicker.vue:236
5953
msgid "Files and folders you recently modified will show up here."
6054
msgstr ""
6155

62-
#: lib/components/FilePicker/FileList.vue:47
56+
msgid "Filter file list"
57+
msgstr ""
58+
59+
msgid "Home"
60+
msgstr ""
61+
6362
msgid "Modified"
6463
msgstr ""
6564

66-
#: lib/legacy.ts:171
6765
msgid "Move"
6866
msgstr ""
6967

70-
#: lib/legacy.ts:171
7168
msgid "Move to {target}"
7269
msgstr ""
7370

74-
#: lib/components/FilePicker/FileList.vue:27
7571
msgid "Name"
7672
msgstr ""
7773

78-
#: lib/components/FilePicker/FilePicker.vue:160
79-
#: lib/components/FilePicker/FilePickerNavigation.vue:61
74+
msgid "New"
75+
msgstr ""
76+
77+
msgid "New folder"
78+
msgstr ""
79+
80+
msgid "New folder name"
81+
msgstr ""
82+
83+
msgid "No files in here"
84+
msgstr ""
85+
86+
msgid "No files matching your filter were found."
87+
msgstr ""
88+
89+
msgid "No matching files"
90+
msgstr ""
91+
8092
msgid "Recent"
8193
msgstr ""
8294

8395
#. FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'
84-
#: lib/components/FilePicker/NcDatetime.vue:36
8596
msgid "sec. ago"
8697
msgstr ""
8798

8899
#. FOR TRANSLATORS: Shorter version of 'a few seconds ago'
89-
#: lib/components/FilePicker/NcDatetime.vue:35
90100
msgid "seconds ago"
91101
msgstr ""
92102

93-
#: lib/components/FilePicker/FileList.vue:8
103+
msgid "Select all entries"
104+
msgstr ""
105+
94106
msgid "Select entry"
95107
msgstr ""
96108

97-
#: lib/components/FilePicker/FileList.vue:37
109+
msgid "Select the row for {nodename}"
110+
msgstr ""
111+
98112
msgid "Size"
99113
msgstr ""
100114

101-
#: lib/toast.ts:242
102115
msgid "Undo"
103116
msgstr ""
104117

105-
#: lib/components/FilePicker/FileListRow.vue:34
106118
msgid "Unset"
107119
msgstr ""
108120

109-
#: lib/components/FilePicker/FilePicker.vue:234
110121
msgid "Upload some content or sync with your devices!"
111122
msgstr ""

0 commit comments

Comments
 (0)