Localizing .Date.Format

I’m using Toml for a specific site’s config.
The site is in Chinese - Traditional (i.e. Taiwanese)

languageCode = "zh-cht"
defaultContentLanguage = "zh-cht"
		contentDir = "content/zh-cht"
		languageName = "語言"
		languagedirection = 'ltr'
		weight = 20

The site is working just fine, except:
In front matter I have:

date_of_event: 2015-09-05

{{ .Params.date_of_event | time.Format ":date_long" }}

This works great, for the English site.

I assume it would localize for Chinese, but it doesn’t.

I believe it’s my config is incorrect, but for the life of me, I can’t understand what, when I work to “delve” into this, I believe I should be using “zh-Hant-TW” somehow but not sure how.

In my sites href lang settings (HTML output) it seems I should be using:

|Chinese (Traditional) (zh-CHT) |zh-CHT| - i.e. <html lang="zh-cht">

Except, I do see an option for:

|Chinese (Traditional) (zh-Hant) |zh-Hant|

Which I don’t totally understand the difference to be honest.

There’s a series of confusions I’m mid, but at the end of the day, how, with the above config do I localize a date with time.format?

Thank you for everyone’s time.

The language tag must match one of these:

The comparison is case-insensitive. You may use underscores or hyphens.

1 Like

Pardon @jmooring dumb question, but what do we consider the “language tag” exactly?
(Thank you as always for the replies/assistance)

zh-cht is your current language tag.

I haven’t used the auto localization of dates (yet) but I think you should use zh-Hant-TW since this is listed in the IANA subtag registry.

Try to change your settings to the following:

languageCode = "zh-hant-tw"
defaultContentLanguage = "zh-hant-tw"
		contentDir = "content/zh-hant-tw"
		languageName = "語言"
		languagedirection = 'ltr'
		weight = 20

EXTRA reply:

Change all your zh-cht to zh-hant-tw since the latter is the one listed in the IANA subtag registry (the official list).

As per the W3C’s Language tags in HTML and XML, language tags should be as short as possible.

  • zh-Hant-TW means Traditional Hanzi as used in Taiwan.
  • zh-Hant means Traditional Hanzi as used anywhere.
  • zh means Hanzi regardless if it is Traditional or Simplified.

Since Hanzi have variations per region/country, zh-Hant-TW is more appropriate. This way if your content is opened from an application/software which have multilingual support, it can adjusts accordingly–for example, speech software can pronounce the words appropriate for the region as opposed to, say, traditional Hanzi as used in Hong Kong (zh-Hant-HK).

Another reason to be specific: in my sites, I use en-PH instead of simply en because Philippine English have official English words (and meanings) that do not exist in any other English variants (just like how the word kangaroo does not exist “officially” in American English to this day but exists in Australian English as well as Philippine English).

I hope it helps. We’re getting off-topic from Hugo. :slight_smile:


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