Wrong localization for date

date_long should return 2 January 2006 for KE time format but instead, we get `January 2, 2006". Time zone and locale are configured correctly (the website is multilingual in English and Swahili).

Just for my peace of mind, please share the languages portion of your site configuration.


  languageCode                            = 'en-KE'
  languageName                            = 'English'
  weight                                  = 1
  languageCode                            = 'sw-KE'
  languageName                            = 'Swahili'
  weight                                  = 2

Localization is driven by the language key, not by LanguageCode. With this in my site config…

defaultContentLanguage = 'en-KE'

languageCode = 'en-KE'
languageDirection = 'ltr'
languageName = 'English'
weight = 1

…everything works as expected.

In the above, the languageCode is not relevant to localization, translation, or collation.

From the documentation:


See the second sentence in the above.

My mistake then. I thought language code was the driver for localization! I guess I still have a lot to learn.

I am getting these errors in my templates after changing the language key. I am trying to debug them in the meantime. (This code throws that error for example when ByTitle is replaced ByDate)

execute of template failed at <$p.ByDate>: can’t evaluate field ByDate in type []interface {}

(I can confirm hat code is the one failing the build @jmooring with en changed to en-KE and sw to sw-KE )

Question: Do I have to rename all my files (I have thousands) to match the language key? They are in format abc.md and abc.sw.md. I cannot debug where this error is coming from (a colleague used the multilingual code extensively in our site, so the code you shared in the link fails in every instance where .ByDate is used.).

Regardless of whether you translate by file name or by directory, the content language designator must match the language key. For example:

defaultContentLanguage = 'en-ke'
defaultContentLanguageInSubdir = true

languageCode = 'en-KE'
languageDirection = 'ltr'
languageName = 'English'
weight = 1

languageCode = 'sw-KE'
languageDirection = 'ltr'
languageName = 'Swahili'
weight = 2
├── _index.en-ke.md
└── _index.sw-ke.md


├── en-ke/
│   └── _index.md
└── sw-ke/
    └── _index.md

I think this is a lot just to localise the date. I will opt for a custom date format per language instead. Thanks for enlightening me though on the language key.

Wise move with thousands of files. Perhaps on the next large project you can do things differently. Remember that localization affects dates, numbers, currencies, percentages, and collation (sort order).

It was a WP site that was moved. A blog with about 10 authors (Multipage is used for listicles). But any new project will definitely consider these issues.

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