Skip to content

Commit

Permalink
fix: Update extract-l10n to also allow extracting strings from prop…
Browse files Browse the repository at this point in the history
…erties

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Sep 24, 2023
1 parent 3045101 commit b2ecabb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
42 changes: 26 additions & 16 deletions build/extract-l10n.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import { GettextExtractor, JsExtractors } from 'gettext-extractor'
import { GettextExtractor, JsExtractors, HtmlExtractors } from 'gettext-extractor'

const extractor = new GettextExtractor()

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

extractor.createHtmlParser([
HtmlExtractors.embeddedJs('*', jsParser),
HtmlExtractors.embeddedAttributeJs(/:[a-z]+/, jsParser),
])
.parseFilesGlob('./src/**/*.vue')

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

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

Expand Down
6 changes: 0 additions & 6 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"

#: src/components/Dialog.vue:81
msgid "Authentication required"
msgstr ""

#: src/components/Dialog.vue:85
msgid "Confirm"
msgstr ""

#: src/components/Dialog.vue:84
msgid "Failed to authenticate, please try again"
msgstr ""

#: src/components/Dialog.vue:83
msgid "Password"
msgstr ""

#: src/main.ts:21
msgid "Password confirmation dialog already mounted"
msgstr ""

#: src/components/Dialog.vue:82
msgid "This action requires you to confirm your password"
msgstr ""

0 comments on commit b2ecabb

Please sign in to comment.