Skip to content

Improve a support for locales with region subtags - #2576

Open
akortunov wants to merge 1 commit into
HangfireIO:mainfrom
akortunov:features/locale_fixes
Open

akortunov wants to merge 1 commit into
HangfireIO:mainfrom
akortunov:features/locale_fixes

Conversation

@akortunov

@akortunov akortunov commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

A follow-up work for #2574.

In upstream Hangfire, locale name is passed to Hangfire Dashboard HTML as a two-letter language name:

<html lang="@CultureInfo.CurrentUICulture.TwoLetterISOLanguageName">

This tag is used as a locale name for Moment.js:

image

As a result, some supported locales become unused in Moment.js:

  1. pt-br becomes just pt instead
  2. zh-cn and zh-tw become just zh, which does not exist in Moment.js, so an English text is used instead

A proposed solution:

  1. Add a new attibute to Hangfire.config, which will store the full locale name.
  2. Try to set a locale for Moment.js by using a full name first, and fall back to current behaviour if target locale was not found.

@odinserj

Copy link
Copy Markdown
Member

Thanks @akortunov! I will check this a bit later, sorry for the delay – need also to dig into the lang attribute to understand whether locale can be used there, not just the two-letter codes.

@burningice2866

Copy link
Copy Markdown
Contributor

Thanks @akortunov! I will check this a bit later, sorry for the delay – need also to dig into the lang attribute to understand whether locale can be used there, not just the two-letter codes.

Yeah, its allowed to use the full lang-region value in the html-attribute

https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag

@akortunov

akortunov commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @akortunov! I will check this a bit later, sorry for the delay – need also to dig into the lang attribute to understand whether locale can be used there, not just the two-letter codes.

Yeah, its allowed to use the full lang-region value in the html-attribute

https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag

Yes, it is possible (I suppose that it would be enough to replace @CultureInfo.CurrentUICulture.TwoLetterISOLanguageName to @CultureInfo.CurrentUICulture.Name).

But this change will affect the whole page instead of just moment.js and may have side effects.

For example - I suppose that ca-ES locale will fall back to en instead of ca in moment.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants