diff --git a/_extensions/i18n/_extension.yml b/_extensions/i18n/_extension.yml index 57cad08..0f03cc7 100644 --- a/_extensions/i18n/_extension.yml +++ b/_extensions/i18n/_extension.yml @@ -4,7 +4,8 @@ version: 1.0.0 quarto-required: ">=1.5.0" contributes: shortcodes: - - 18n_select.lua + - i18n_select.lua + - i18n_tags.lua revealjs-plugins: - name: RevealI18n stylesheet: diff --git a/_extensions/i18n/i18n_tags.lua b/_extensions/i18n/i18n_tags.lua new file mode 100644 index 0000000..6cdc3bd --- /dev/null +++ b/_extensions/i18n/i18n_tags.lua @@ -0,0 +1,18 @@ + +local function isEmpty(o) + return o == nil or o == '' +end + +return { + ['i18n-key'] = function(args, kwargs) + + local i18n_key = args[1] or "" + local tag = pandoc.utils.stringify(kwargs["tag"]) + if isEmpty(tag) then + tag = "span" + end + local element_html = string.format('<%s data-i18n-key="%s">', tag, i18n_key, tag) + + return pandoc.RawInline('html', element_html) + end +} diff --git a/example.qmd b/example.qmd index 6c86581..44f0df8 100644 --- a/example.qmd +++ b/example.qmd @@ -70,26 +70,26 @@ revealjs-plugins: - i18n --- -# +# {{< i18n-key "morning" >}} -## +## {{< i18n-key "getting-up" >}} -- -- +- {{< i18n-key "alarm" >}} +- {{< i18n-key "bed1" >}} -## +## {{< i18n-key "breakfast" >}} -- -- +- {{< i18n-key "eggs" >}} +- {{< i18n-key "coffee" >}} -# +# {{< i18n-key "evening" >}} -## +## {{< i18n-key "dinner" >}} -- -- +- {{< i18n-key "spaghetti" >}} +- {{< i18n-key "wine" >}} ## -- -- +- {{< i18n-key "bed2" >}} +- {{< i18n-key "sheep" tag="h6">}}