Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.74k stars 2.3k forks source link

`[p]set locale` does not accept "Serbian (Cyrillic)" as valid #5812

Open karlsbjorn opened 2 years ago

karlsbjorn commented 2 years ago

What Red version are you using?

3.4.17

Cog name

Core

Command name

set locale

What did you expect to happen?

After typing [p]set locale sr-SP the bot should respond with Locale has been set. and switch to using the Serbian Cyrillic locale.

What actually happened?

The bot responds with Invalid language code. Use format: en-US and the locale does not change.

How can we reproduce this error?

  1. Type [p]set locale sr-SP
  2. Wait for bot to respond

Anything else?

I'm aware that the "Serbian (Cyrillic)" translation for core Red is currently at 0%, but that shouldn't matter since "Serbian (Latin)" is also at 0% and yet the bot accepts that locale (with [p]set locale sr-CS) just fine.

There are also technically other locale codes for "Serbian (Cyrillic)" but since sr-SP is the only one crowdin uses (and the other locale codes don't work with crowdin), the bot should allow it.

Kowlin commented 2 years ago

So this one was a fun one to dig through. It appears that Babel (the overlying lib that handles country code checking for us) doesn't appear to support script indicators within locale codes, meaning that we cannot make any distinguish between Latin and Cyrillic scripts. As for the country code you've provided, I think you're looking for sr-RS (source).

karlsbjorn commented 2 years ago

Hey Kowlin, thanks for looking into the issue! Unfortunately sr-RS doesn't work since Crowdin only provides files with sr-SP and sr-CS locales (examples from the latest Red release: sr-SP, sr-CS). I tested with a third-party cog to see if sr-RS would show translations from either of the two locales, but it does not.

There's also some other information that might help: [p]set locale sr-cyrl-RS and [p]set locale sr-latn-RS are both accepted by the bot, but after typing [p]set showsettings the actual locale seems to be forcefully set to sr-RS instead. image

So it looks like it does support script indicators, sort of? It just ignores them.