Hey,
I want to incrementally translate my website. If a post is not translated, the content should be displayed in the default language instead.
Using mounts is an often suggested solution: Do all page bundles need localized copies once you add a new language? - #12 by jmooring
Is there an alternative in case I want to keep using filenames with language codes? (Multilingual mode)
Thank you very much in advance!
You can use mounts to fill in the gaps when translating by file name, but you must exclude the language identifier from the filename for content files in the default language. For example:
content/
βββ posts/
β βββ _index.de.md
β βββ _index.md <-- excludes language identifier
β βββ post-1.de.md
β βββ post-1.md <-- excludes language identifier
β βββ post-2.md <-- excludes language identifier
βββ _index.de.md
βββ _index.md <-- excludes language identifier
Then you can do this:
[[module.mounts]]
source = 'content'
target = 'content'
# Fills gaps in `de` with content from default language
[[module.mounts]]
source = 'content'
target = 'content'
lang = 'de'
# Fills gaps in `fr` with content from default language
[[module.mounts]]
source = 'content'
target = 'content'
lang = 'fr'
The only limitation with this approach (when compared to translating by directory) is that you are always filling in the gaps with content from the default content languageβ¦ you cannot cascade βupβ from one language to the next.
Try it:
git clone --single-branch -b hugo-forum-topic-54270 https://github.com/jmooring/hugo-testing hugo-forum-topic-54270
cd hugo-forum-topic-54270
hugo server