langToLocale() handles `cz`, but the Czech language key is `cs`

Open Beginner friendly
#6,641 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Read client/src/app/infrastructure/utils/lang-to-locale.ts and compare its Czech case with the language keys in client/src/app/domain/definitions/languages.ts and the existing Czech handling in langToTimeLocale(). Change the locale mapping to use the Czech language key; done means langToLocale('cs') returns cs-CZ instead of the fallback.

Written by the indexing model from the issue text.

Description

Describe the bug

langToLocale() in client/src/app/infrastructure/utils/lang-to-locale.ts has case `cz` , but the
client's language key for Czech is cs (client/src/app/domain/definitions/languages.ts:
en, de, cs, fr, it, es, nl, ru). langToTimeLocale() in the same file already uses cs
(date-fns/locale/cs). So with the language set to Czech, langToLocale('cs') falls through to the
default branch (lt-LT, an ISO-like date format) instead of cs-CZ.

How to Reproduce

  1. Set the interface language to Czech.
  2. Look at any formatted date/time that goes through langToLocale(): it is rendered in the
    fallback lt-LT format.

I could not test this with a Czech user account; it is from reading the code on main @ 551421b.

Expected behavior

Czech uses cs-CZ.

Additional context

One-word fix (case `cz` → case `cs` ), happy to open a PR:

diff --git a/client/src/app/infrastructure/utils/lang-to-locale.ts b/client/src/app/infrastructure/utils/lang-to-locale.ts
index f857b8f..58fbc51 100644
--- a/client/src/app/infrastructure/utils/lang-to-locale.ts
+++ b/client/src/app/infrastructure/utils/lang-to-locale.ts
@@ -15,7 +15,7 @@ export function langToLocale(lang: string): string {
         case `de`: {
             return `de-DE`;
         }
-        case `cz`: {
+        case `cs`: {
             return `cs-CZ`;
         }
         default: {

Found while preparing a Portuguese (Brazil) translation. Reported by Marcos Aguiar ([email protected]).

Dominant language
TypeScript
Stars
35
Forks
53
Avg merge
1d 6h
Merged PRs (30d)
49

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenSlides/openslides-client

All issues in OpenSlides/openslides-client

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.