Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo ≥0.76.* i18n breaks authorbox_name string #237

Closed
Vimux opened this issue Oct 15, 2020 · 4 comments · Fixed by #245
Closed

Hugo ≥0.76.* i18n breaks authorbox_name string #237

Vimux opened this issue Oct 15, 2020 · 4 comments · Fixed by #245

Comments

@Vimux
Copy link
Owner

Vimux commented Oct 15, 2020

After upgrading to Hugo 0.76.*, the authorbox_name i18n string stops working correctly.

Hugo version

$ hugo version
Hugo Static Site Generator v0.76.5/extended darwin/amd64 BuildDate: unknown

Theme is up to date?

Yes. 8c2da72

Expected behavior

Screenshot Screenshot without bug

Current behavior

Screenshot Screenshot with bug demonstration

Problem

exampleSite demo build log shows the following warning messages since bumping to Hugo 0.76.*:

WARN 2020/10/12 13:40:31 Failed to get translated string for language "en" and ID "authorbox_name": template: :1:9: executing "" at <.Count>: can't evaluate field Count in type string
WARN 2020/10/12 13:40:31 Failed to get translated string for language "en" and ID "authorbox_name": template: :1:9: executing "" at <.Count>: can't evaluate field Count in type string
WARN 2020/10/12 13:40:31 Failed to get translated string for language "en" and ID "authorbox_name": template: :1:9: executing "" at <.Count>: can't evaluate field Count in type string
WARN 2020/10/12 13:40:31 Failed to get translated string for language "en" and ID "authorbox_name": template: :1:9: executing "" at <.Count>: can't evaluate field Count in type string
WARN 2020/10/12 13:40:31 Failed to get translated string for language "en" and ID "authorbox_name": template: :1:9: executing "" at <.Count>: can't evaluate field Count in type string

As a result, i18n string (authorbox_name) does not work as before.

Steps to reproduce

Prerequisites: git, hugo 0.76.*

  1. Clone this repository and cd in the exampleSite dir

    git clone /~https://github.com/vimux/mainroad.git
    cd mainroad/exampleSite/
  2. Run Hugo server with the following command:

    hugo server --themesDir ../..
  3. Visit http://localhost:1313/post/hugoisforlovers/ in your browser and scroll to the bottom of the page.


gohugoio/hugo#7822

kofuk added a commit to kofuk/Mainroad that referenced this issue Nov 3, 2020
@yuqingc
Copy link
Contributor

yuqingc commented Nov 4, 2020

Is there a compromising way to fix the authorbox's display temporarily for those who use Mianroad before this issue is fixed?

@Vimux
Copy link
Owner Author

Vimux commented Nov 4, 2020

Is there a compromising way to fix the authorbox's display temporarily for those who use Mianroad before this issue is fixed?

I don't have time to investigate this problem (yet). Options:

  1. Don't upgrade Hugo just because, especially without testing. You will avoid this and other problems in future.

  2. If you want to use Hugo ≥0.76, you can override specific i18n key-value without touching whole theme's i18n file. Lookup order. It's not ideal, but...

    • Add i18n/en.yaml within site's root:
    # /~https://github.com/vimux/mainroad/issues/237
    - id: authorbox_name
      translation: "About {{ . }}"

    Hugo merge this particular value. If you use other or multiple languages, you should make similar according changes.

digitalbricklayer pushed a commit to digitalbricklayer/techteapotcom that referenced this issue Nov 4, 2020
@Vimux Vimux changed the title Hugo 0.76.* i18n breaks authorbox_name string Hugo ≥0.76.* i18n breaks authorbox_name string Jan 6, 2021
Vimux added a commit that referenced this issue Jan 9, 2021
This is due to an upstream issue in Hugo ≥0.76 (Upgrade to go-i18n v2).
Three months have passed, so I have to look for workarounds on our side.
The most popular option (replace `.Count` to `.`) doesn't suit us
because it breaks backward compatibility.

This fix will allow us to preserve backward compatibility with older
versions.

Fix #237
@Vimux Vimux closed this as completed in #245 Jan 9, 2021
@mcdragonsi
Copy link

I am a bit lost. Is this issue fixed and if so, how do I apply it to Mainroad?

@arashThr
Copy link

arashThr commented Jun 7, 2021

@mcdragonsi Make sure you're on master and you've pulled the latest changes. Then, if you have custom translations file, change {{ .Count }} in it to {{ .Name }}

gmtborges pushed a commit to gmtborges/Mainroad that referenced this issue Jan 22, 2023
This is due to an upstream issue in Hugo ≥0.76 (Upgrade to go-i18n v2).
Three months have passed, so I have to look for workarounds on our side.
The most popular option (replace `.Count` to `.`) doesn't suit us
because it breaks backward compatibility.

This fix will allow us to preserve backward compatibility with older
versions.

Fix Vimux#237
nikolaswise pushed a commit to nikolaswise/Mainroad that referenced this issue Dec 20, 2024
This is due to an upstream issue in Hugo ≥0.76 (Upgrade to go-i18n v2).
Three months have passed, so I have to look for workarounds on our side.
The most popular option (replace `.Count` to `.`) doesn't suit us
because it breaks backward compatibility.

This fix will allow us to preserve backward compatibility with older
versions.

Fix Vimux#237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants