-
DescriptionUse-case: better multilingual support is my current problem, but I think would be useful in many cases. Currently, one can do per-language alternates, as shown in the documentation: ---
title: "My Document"
author: "Norah Jones"
date: 5/22/2022
lang: fr
language:
en:
title-block-published: "Updated"
fr:
title-block-published: "Mis à jour"
--- Then one can set the language in It would be really nice if one could also ---
title: "My Document"
author: "Norah Jones"
date: 5/22/2022
lang: it
language:
en:
title: "My post number one"
it:
title: "Il mio post numero uno"
--- Or are there other ways to achive something similar? I found no way to use variables inside shortcodes, basically something like I'm thinking about just having the three titles in the front-matter, and using a lua filter to pick one and set the "main" title based on it, but before I start reading into this — are there any easy solutions I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
If you are using profile, then you can set the title in it. This being said, this has been extensively discussed already:
I believe all these issues/discussions summarised various proof of concept and what is currently possible. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I spent hours researching this but somehow missed your first and last link which do answer my question, thank you! I'll solve this with a Lua filter, checked it out and it's easier than it sounded initially. Thank you! |
Beta Was this translation helpful? Give feedback.
-
This does what I want, basically, I'll swap prints for real logging etc. but otherwise I have a solution to the problem ---
title: "Publications and Awards"
titles:
en: "Publications and Awards"
de: "Veröffentlichungen"
filters: [./filters/conditional-metadata.lua]
function Meta(m)
local profiles = quarto.project.profile
if not profiles then
-- TODO: missing YAML key? Empty YAML key?..
-- TODO even more later: filter multiple profiles to use the language one
return m
end
local profile = profiles[1]
-- If we have a named profile, save it, otherwise return
if profile then
print("Profile: " .. profile)
m.active_profile = profile
else
return m
end
if m.titles then
local titles = m.titles
if titles[profile] then
newtitle = pandoc.utils.stringify(titles[profile])
oldtitle = pandoc.utils.stringify(m.title)
-- log both if they differ
if newtitle ~= oldtitle then
m.title = newtitle
-- print("Old title:" .. oldtitle)
-- print("New title:" .. newtitle)
print(oldtitle .. " => " .. newtitle)
end
else
print("Title for profile " .. profile .. " not found among ")
for lang, title in pairs(titles) do -- Table iteration.
print(" " .. lang .. ": " .. pandoc.utils.stringify(title))
end
end
end
return m
end
|
Beta Was this translation helpful? Give feedback.
Sorry, I spent hours researching this but somehow missed your first and last link which do answer my question, thank you!
I'll solve this with a Lua filter, checked it out and it's easier than it sounded initially.
Thank you!