Single HTML content file for multiple languages

#1

I understand that multilingual pages can be served by creating files like this:

/content/posts/my-first-post.en.html
/content/posts/my-first-post.ar.html

But I have a situation where the whole html structure is exactly the same for all languages except for the strings and text. I want to create one single html file and make it be the skeleton for all served languages.

I understand that this can be achieved by i18n string translations but what I see problematic with this approach is that all string translations must be written in what can become huge files inside:

i18n/en.yaml or themes/theme-name/i18n/en.yaml

I would prefer creating i18n files per content page and not per site as whole.

How to do that? Thank you.

#2

I hope the question above is clear.

It is just yesterday I heard about Hugo for the first time and I like the simplicity of the framework but for my projects, content translation is important.

#3

I suspect what you are looking for is layout files (which can also be language specific, but they do not have to be).

1 Like
#4

What I mean is:

/posts/first-post.template.html

Which includes i18n string replacements e.g. <h2>{{ $t.our_sevices) }</h2>

And the i18n files should be under e.g. /i18n/posts/first-post

the /posts/first-post.template.html should be rendered differently depends on language prefix in URL e.g. /en or /ar.

I think such functionality should be implemented.

In short, the i18n files should be content page based and not necessarily site-wide.

#5

I don’t understand what you want, but I suspect what you want is possible if you wrap your mind around it.