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 · 1 comment · Fixed by #6539 or #6540
Closed

Translations does not work in ExecuteAsTemplate #6331

zygimantas-skinkys opened this issue Sep 13, 2019 · 1 comment · Fixed by #6539 or #6540
Labels
Bug
Milestone

Comments

@zygimantas-skinkys
Copy link

@zygimantas-skinkys zygimantas-skinkys commented Sep 13, 2019

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
@confususs confususs mentioned this issue Nov 7, 2019
@alex-shpak

This comment has been minimized.

Copy link

@alex-shpak alex-shpak commented Nov 11, 2019

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].

@bep bep added Bug and removed NeedsInvestigation labels Nov 26, 2019
bep added a commit to bep/hugo that referenced this issue Nov 26, 2019
@bep bep closed this in #6539 Nov 26, 2019
@bep bep closed this in 96f0965 Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.