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.2k stars 2.9k forks source link

New Publication Types don't pull from the new language translations #1662

Closed btihen closed 4 years ago

btihen commented 4 years ago

Custom translations in i18n/en.yaml aren't being used or new publication keys - but are read from the file: themes/academic/i18n/en.yaml - which means I will loose my translations with updates to the academic theme submodule.

Describe the bug

Following the instructions on: https://sourcethemes.com/academic/docs/managing-content/#create-a-publication in the section: Modifying Publication Types only partially work. The new publication types use the translation: Uncategorized not the new word.

To Reproduce

Steps to reproduce the behavior: 1) create a new publication type list:

cat <<EOF > data/publication_types.toml
types = [ "pub_uncat",        # 0
          "pub_conf",         # 1
          "pub_journal",      # 2
          "pub_preprint",     # 3
          "pub_report",       # 4
          "pub_book",         # 5
          "pub_book_section", # 6
          "pub_thesis",       # 7
          "pub_patent",       # 8
          "pub_webpage",      # 9
          "pub_podcast",      # 10
          "pub_video",        # 11
          "pub_blog"          # 12
        ]
EOF

2) copy the en language file: cp themes/academic/i18n/en.yaml i18n/en.yaml

3) add the new publication type translations:

cat <<EOF >> i18n/en.yaml

- id: pub_webpage
  translation: Webpage

- id: pub_podcast
  translation: Podcast

- id: pub_video
  translation: Video

- id: pub_blog
  translation: Blog
EOF

4) delete publication folders (to be sure there are not residual old pages)

rm -rf public/publication
rm -rf public/publication_types

5) change the publication page to use the new index in my case 12 (Blog) sed -i '' -e 's/publication_types\:\ [\"0\"]/publication_types\:\ [\"12\"]/g' content/publication/**/index.md

6) generate the updated publication pages:

hugo server 
# or 
hugo -d public
#  hugo --i18n-warnings | grep i18n
Building sites …
i18n|MISSING_TRANSLATION|en|pub_webpage
i18n|MISSING_TRANSLATION|en|pub_podcast
i18n|MISSING_TRANSLATION|en|pub_video
i18n|MISSING_TRANSLATION|en|pub_blog

I did find that I can add the translations to the file: themes/academic/i18n/en.yaml instead of i18n/en.yaml and I don't get the translation errors and the publication page works as expected.

Expected behavior

I expect files in i18n/en.yaml to be read instead of only in the themes/academic/i18n/en.yaml file. I find it dangerous to have to have my language extensions to be in the submodule I don't control as updates will likely mean redoing these translations and putting the custom translations in i18n/en.yaml is the instructions on the page: https://sourcethemes.com/academic/docs/managing-content/#create-a-publication

Technical details:

btihen commented 4 years ago

Its also odd that the first Uncategorized is there - even without any articles associated with it.

gcushen commented 4 years ago

I did find that I can add the translations to the file: themes/academic/i18n/en.yaml instead of i18n/en.yaml and I don't get the translation errors and the publication page works as expected.

That would imply that it's not a bug in Academic. The multilingual system and concept of overriding files is implemented by Hugo. Hence, it would appear to be a Hugo related issue/question - feel free to reach out in the Hugo Forums or chat. Also, Hugo team provide documentation on this process in the Hugo Docs.

btihen commented 4 years ago

Ok - thanks, but maybe that section of the docs needs to be removed - since tose instructions don't work. If I find a better solution I'll make a PR for the working solution.