Hi, my website contains multiple products’ documents in sub-folders, and some of them have both English and Chinese version, some have only English version.
For those documents that have only English version, I’d like to hide/disable the language selector.
I have no idea where to start. Would you shed some light?
If the above requirement is hard to implement, is there a way to “fall back” to default (English) version when a page doesn’t have Chinese version?
I think the first thing to do is the automatic “fall back” mechanism, because without falling back to the default English page, a user may navigate to a non-existing Chinese page by clicking links in current page.
It woud be nice if Hugo provided this fall back feature. I have no idea how to implement it.
IMHO theres No OOTB here. remember, If there’s no translation, you have no page where you can get something like a link, title and all these can be localized.
you have
Page.Language
language of current page
Page.AllTranslations
which contains all translated Pages available for a current page (incl the current page)
Page.Translations
same as above but without current page
site.Languages
contains all languages that are defined.
so the difference of AllTranslations.Language and site.Languages are the ones not translated.
the pages in Translations are the one where a translation exists.
There are some topics in the forum that handle that topic incl. code - try to search for that “missing translation fallback …”
@irkode Thank you so much for more information.
When I started this thread, I’ve also post my question on Docsy’s discussion board, and I got an answer from there. It seems working. At least I didn’t see a problem with that approach.
For details, here is the link to that discussion: