Skip to content

Commit

Permalink
fix(l10n): Extract translations also from vue SFC template attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Aug 27, 2023
1 parent 15c0215 commit 968240f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 43 deletions.
48 changes: 29 additions & 19 deletions build/extract-l10n.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import { GettextExtractor, JsExtractors } from 'gettext-extractor'
import { GettextExtractor, JsExtractors, HtmlExtractors } from 'gettext-extractor'

let extractor = new GettextExtractor();
const extractor = new GettextExtractor()

extractor
.createJsParser([
JsExtractors.callExpression('t', {
arguments: {
text: 0,
}
}),
JsExtractors.callExpression('n', {
arguments: {
text: 1,
textPlural: 2,
}
}),
])
.parseFilesGlob('./lib/**/*.@(ts|js|vue)');
const jsParser = extractor.createJsParser([
JsExtractors.callExpression('t', {
arguments: {
text: 0,
},
}),
JsExtractors.callExpression('n', {
arguments: {
text: 0,
textPlural: 1,
},
}),
])
.parseFilesGlob('./lib/**/*.@(ts|js)')

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

extractor.printStats();
// remove references to avoid conflicts
extractor.getMessages().forEach((msg) => {
msg.references = []
})

extractor.savePotFile('./l10n/messages.pot')

extractor.printStats()
69 changes: 45 additions & 24 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,113 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

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

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

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

#: lib/components/FilePicker/FilePickerNavigation.vue:57
msgid "All files"
msgstr ""

#: lib/filepicker.ts:207
msgid "Choose"
msgstr ""

#: lib/filepicker.ts:207
msgid "Choose {file}"
msgstr ""

#: lib/filepicker.ts:214
msgid "Copy"
msgstr ""

#: lib/filepicker.ts:214
msgid "Copy to {target}"
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:249
msgid "Could not create the new folder"
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:159
#: lib/components/FilePicker/FilePickerNavigation.vue:65
msgid "Create directory"
msgstr ""

msgid "Current view selector"
msgstr ""

msgid "Favorites"
msgstr ""

#: lib/components/FilePicker/FilePickerBreadcrumbs.vue:87
msgid "File name cannot be empty."
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:235
msgid "Filepicker sections"
msgstr ""

msgid "Files and folders you mark as favorite will show up here."
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:233
msgid "Files and folders you recently modified will show up here."
msgstr ""

#: lib/components/FilePicker/FileList.vue:47
msgid "Filter file list"
msgstr ""

msgid "Home"
msgstr ""

msgid "Mime type {mime}"
msgstr ""

msgid "Modified"
msgstr ""

#: lib/filepicker.ts:222
msgid "Move"
msgstr ""

#: lib/filepicker.ts:222
msgid "Move to {target}"
msgstr ""

#: lib/components/FilePicker/FileList.vue:27
msgid "Name"
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:159
#: lib/components/FilePicker/FilePickerNavigation.vue:61
msgid "New"
msgstr ""

msgid "New folder"
msgstr ""

msgid "New folder name"
msgstr ""

msgid "No files in here"
msgstr ""

msgid "No files matching your filter were found."
msgstr ""

msgid "No matching files"
msgstr ""

msgid "Recent"
msgstr ""

#: lib/components/FilePicker/FileList.vue:8
msgid "Select all entries"
msgstr ""

msgid "Select entry"
msgstr ""

#: lib/components/FilePicker/FileList.vue:37
msgid "Select the row for {nodename}"
msgstr ""

msgid "Size"
msgstr ""

#: lib/toast.ts:242
msgid "Undo"
msgstr ""

#: lib/components/FilePicker/FilePicker.vue:231
msgid "unknown"
msgstr ""

msgid "Upload some content or sync with your devices!"
msgstr ""

0 comments on commit 968240f

Please sign in to comment.