HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.19k stars 2.9k forks source link

Add option to always show language chooser #166

Closed yiluheihei closed 6 years ago

yiluheihei commented 7 years ago

It's very nice for the language choose navbar. While click into a internal link, such as a Project demonstrate or a post, the language choose navbar is disappeared.

gcushen commented 7 years ago

Yes, this is correct functionality. The language bar will only appear for pages that have been translated. If you provide a translation for a page, then the language chooser will show the user what languages that page is available in. Therefore, if you would like a language bar for your whole site, you will need to translate all of your pages.

yiluheihei commented 7 years ago

Thank your very much. Sometimes we need to switch the web frequently between different languages, however, not all the pages was translated is very common (e.g. we write different posts in different languages).

In view of this, it will be awesome if a params (such as languageChooserInTranstlatedPage) was supported. If true, the language chooser will show the pages user translated. Otherwise, the language will show in the whole site and just linked to the root link or the home page of the other language site.

Thanks for your attention.

gcushen commented 7 years ago

So we could have an alwaysShowLanguageChooser option in config.toml. If alwaysShowLanguageChooser is true, language chooser is always displayed. If translation is available for page, it links to the translation, otherwise it links to the translated homepage for that language?

yiluheihei commented 7 years ago

Yes, that's it.

pzhaonet commented 7 years ago

@yiluheihei Hi. I am wondering how to display a language chooser dropdown navbar like your website? Thank you!

I do not know how to add such a navbar. Instead I add the links in 'config.toml':

[[Languages.en.menu.main]]
  name = "中文"
  url = "../zh"
  weight = 7

[[languages.zh.menu.main]]
  name = "EN"
  url = "../en"
  weight = 7
gcushen commented 7 years ago

@dapengde the language chooser is automatically displayed when you translate your content. For example, in content/home/ you can have about.md for your default language (e.g. Chinese) and about.en.md for your English translation. The language chooser drop-down will automatically display. You can find more info about translating your website in Academic's documentation.

pzhaonet commented 7 years ago

@gcushen Sorry, I missed the update #151 somehow. Thank you! Now there is!

kerim commented 7 years ago

Wondering what I'm doing wrong?

From config.toml:

# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = false
# Configure the English version of the website.
[Languages]
[languages.en]
  title = "P. Kerim Friedman"

[Languages.zh-tw]
  title = "傅可恩"

In themes/academic/i18n I have created a file in themes/academic/i18n/zh-tw.yaml with the traditional character versions of themes/academic/i18n/zh.yaml And I edited languages.yaml to include "zh-tw" as well as "zh". (I also tried just using "tw" instead of "zh-tw" in case the standard approach was a problem for parsing, but that didn't help either.)

And in /content/home I have each file listed twice, once as [name].en.md and again as [name].zh-tw.md (I also tried it without specifying ".en." for the English files - but the result was the same.)

However, the end result is that my site title appears in Chinese, and the text like "interests" and "education" appears in Chinese (all as per the i18n/zh-tw.yaml file and the config.toml says), but the pages all appear twice with no multilingual menu to switch between languages.

Am I missing a step? Thanks for your help.

UPDATE: When running hugo server --watch it says: Built site for language zh-tw. This makes me think it is not building the English version as well?

kerim commented 7 years ago

Problem solved!!! [languages.en] needed to be [Languages.en]!!!

Note that the use of lowercase is how it is in exampleSite/config.toml, but I don't know if that is a bug that needs to be fixed, or if it didn't work because of something I did? (I have a [Languages] section I added above that.)

gcushen commented 7 years ago

Going back to the original issue towards the beginning of this thread, it appears like it may be somewhat related to or dependent on #256 ...

likanzhan commented 4 years ago

So we could have an alwaysShowLanguageChooser option in config.toml. If alwaysShowLanguageChooser is true, language chooser is always displayed. If translation is available for page, it links to the translation, otherwise it links to the translated homepage for that language?

Has this function been incorporated in the new version? Thanks

gcushen commented 4 years ago

@likanzhan this issue is currently blocked by the lack of Hugo functionality in this area. I requested Hugo team facilitate this in https://github.com/gohugoio/hugo/issues/5612 . Feel free to support that request and add your thumbs up - it looks like Bep is currently planning it for Hugo v0.70.

Note that there are workarounds which some users are using in the meantime, for example