Extracting i18n strings using goi18n

This is not a hugo question per se, but I wonder if this community might be able to help. I am attempting to extract strings from my template files (layouts, partials, shortcodes, etc) using go-i18n and not having much luck.

I have the goi18n CLI installed and can run goi18n, but so far - I can only get it to produce empty files called active.en.toml.

To attempt a test, I have a file:

that contains the following link:

<a href="https://discourse.mcneel.com/c/gallery/">{{ i18n "gallery" }}</a>

and I would like to run goi18n to produce a file called:


with the following contents:

other = "gallery" 

Does anyone know how to do that? Unfortunately, goi18n -help isn’t much help.

this one?

Correct. goi18n extract is the command that I’m attempting to use. It produces empty (zero KB) active.en.toml files, but I suspect I’m just not finding the documentation on how to run it on specific files (I’ve tried all the obvious things) or run it recursively on folders. For example, I’ve tried:

goi18n extract /themes/my-theme/layouts/partials/site-navigation.html

that contains the following link:

<a href="https://discourse.mcneel.com/c/gallery/">{{ i18n "gallery" }}</a>

and it produces an empty file.

If someone could provide a sample working goi18n extract command, I suspect I’d see the obvious error of my ways.

Can you put a simple repo online so we can check this out? It’s always good to see the full code, there might be something “blinding” the extract function around the code lines in question.

Will do. I’ll gin something up and post it soon. (I just suspected that I was missing something obvious that someone else would see.)

Did you find a solution?

No, I did not, and I apologize because I got side-tracked on other projects. I still intend to post a sample project where this is failing…it should be pretty trivial to reproduce with a boilerplate Hugo site though (famous last words). I suspect it’s just me using the goi18n incorrectly…but until I show the details of exactly what I’m doing, it won’t be obvious to anyone. It’s not off my radar.