Multilingual, Multi country, multi currency, Multi-domain support

Hi there,

can Hugo support multilingual with multi currency and multi country without the need of duplication

use case:

Tour site with tours in multiple countries

2 Countries:

  • Spain
  • France

3 Currencies:

  • US dollar $
  • European euro €
  • British pound

3 Languages:

  • English
  • Spanish
  • French

From what I understand is to generate:

  • en
  • en-US
  • en-UK
  • fr
  • fr-FR
  • es
  • es-ES

I need to create 6 directories (even if there are basically just 3 languages). The only difference between en-US and en-UK will be the default currency.

can I go by using Hugo just create 3 directories and let the languages

  • en-US
  • en-UK

share the language directory en/

other then the currency each language will have separate .tld as follow:

  • .com

    • en
    • en-US
  • .co.uk

    • en-UK
  • .fr

    • fr-FR
  • .es

    • es-ES

thanks

Yes, I think this is what you want.

git clone --single-branch -b hugo-forum-topic-36716 https://github.com/jmooring/hugo-testing hugo-forum-topic-36716
cd hugo-forum-topic-36716
hugo server

Notes:

  • Hugo localizes but does not convert currency amounts.
  • To take advantage of Hugo’s localization capabilities, the language tag must match one of the locale keys on this list . For example, use en_us instead of en-us. See this issue.
  • en_uk is not a valid locale. Use en_gb instead.
2 Likes

Short answer yes.

It supports those cases. Multilingual docs can be found here:

https://gohugo.io/content-management/multilingual/

For currencies you will have to do some minor coding using the information found here:

lang | Hugo (gohugo.io)

I’m not sure it’s a default case but putting the Currency format in the config for the language should work and then just call it with the language.currency or whatever label you apply whenever you use currency.

1 Like

thanks @tracykev

I didn’t knew this, so I simply used the Hugo {{ range .Translations }} and then was trying to add currency symbol and calculation in layouts for each currency.

Thanks for this trick!

thanks @jmooring

Once again your response is at another level respect :man_bowing:

  • Hugo localizes but does not convert currency amounts.

no worries, using this suggestion of @tracykev I simply add rates for each currency in config.yaml file using US$ as base rate value of 1 and provided the rate difference euro : 0.88 and did the calculation in the layouts it works fine

use en_us instead of en-us

thanks for correcting this I was reading an older blog without realising it might have changed in a Hugo version

thanks for sharing the local keys list its really impressive with months days of week etc. is this what Hugo use by default or can Hugo make benefit of this and automatically apply the months/days format from the file

thanks for taking the time to help

Hugo uses this data to localize dates, numbers, currency amounts, and percentages when calling the functions below:

The related functions are:

In the example that I posted, the home page of each of the four language sites has an example of date and currency localization. Compare the home pages of the four sites to see how the same value is localized.

4 Likes

This works great

now having

  • en
  • en-US
  • en-UK

doesnt make much sense as its same language. Does Hugo have the possibility to keep language as 2 separate values “language” and “the tag after the language-” like en-GB

so I can have 2 selectors instead of a single language selector dropdown

Screenshot 2022-01-24 at 4.13.48 PM

thanks for taking the time

First, as I noted previously, en_uk in an invalid locale. Use en_gb instead.

Second, I’m not sure why you need en, en_us, and en_gb. It seems like en_us and en_gb would be sufficient.

Third, by splitting language and locale into two controls, it seems like you are generating additional work for the visitor. I’d rather pick one and be done with it.

Finally, yes you can split the control. Just combine the values in the onChange event.

Hi @jmooring thanks for the quick response here

I was confused when reading this old comment where someone mentioned that :

’gb’ ← fails, should be Great Britain, but ‘uk’ works

the main difference is the date format, country code phone format and currency dollar or pound etc

I will use the google location api to auto select country for the user

are you referring to the regular old js onchange="" or is this a Hugo functionality do you have any example of this.

thanks again your feedback gave me much needed Hugo knowledge

I provided a working example that uses current capabilities. Old comments are… old.

I understand the difference between en_us and en_gb. I just didn’t understand the need for a generic en locale.

Yes.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.