Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lexers/html-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class HTMLLexer extends BaseLexer {

this.attr = options.attr || 'data-i18n'
this.optionAttr = options.optionAttr || 'data-i18n-options'
this.innerTextDefaultValue = options.innerTextDefaultValue ?? false
}

extract(content) {
Expand All @@ -26,6 +27,17 @@ export default class HTMLLexer extends BaseLexer {
}
}

// whether to fill the default value
if (
(!options || options.defaultValue == undefined) &&
that.innerTextDefaultValue &&
$node.text()
) {
if (!options) options = {}
const value = $node.text()
options.defaultValue = value
}

for (let key of keys) {
// remove any leading [] in the key
key = key.replace(/^\[[a-zA-Z0-9_-]*\]/, '')
Expand Down