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

Translations does not work in ExecuteAsTemplate #6331

Closed
zygimantas-skinkys opened this issue Sep 13, 2019 · 2 comments · Fixed by #6539 or #6540
Closed

Translations does not work in ExecuteAsTemplate #6331

zygimantas-skinkys opened this issue Sep 13, 2019 · 2 comments · Fixed by #6539 or #6540
Milestone

Comments

@zygimantas-skinkys
Copy link

i18n translations does not work in assets.

This is how I process my JS file:

{{ $scriptJS := resources.Get "js/script.js" | resources.ExecuteAsTemplate (printf "%s/js/script.js" .Lang ) . | resources.Minify | fingerprint }}

I’m using translations in an usual way:

{{T "translations_key"}}

I get my script.js file for every language but only with English translations(English being main language of the site).

Hugo version:
Hugo Static Site Generator v0.57.0-9B00E647/extended linux/amd64 BuildDate: 2019-08-14T08:12:12Z

OS:

Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

Related discussions:
https://discourse.gohugo.io/t/is-it-possible-to-use-translations-in-assets/20726
https://discourse.gohugo.io/t/style-css-in-multilingual-mode/20754/2

@bep bep changed the title Translations does not work in assets Translations does not work in ExecuteAsTemplate Sep 13, 2019
@bep bep added this to the v0.59 milestone Sep 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Oct 21, 2019
@alex-shpak
Copy link

I can confirm for
Hugo Static Site Generator v0.59.0/extended darwin/amd64 BuildDate: unknown

Outside of ExecuteAsTemplate i18n function works as expected, inside it returns default lang translation.
For now as workaround I use .Site.Params, and lang specific param, e.g. [languages.en.params].

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants