Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Better LocalizationProtocol interface. #1104

Open
elenakrittik opened this issue Sep 8, 2023 · 0 comments
Open

i18n: Better LocalizationProtocol interface. #1104

elenakrittik opened this issue Sep 8, 2023 · 0 comments
Labels
feature request Request for a new feature t: refactor/typing/lint Refactors, typing changes and/or linting changes

Comments

@elenakrittik
Copy link
Contributor

elenakrittik commented Sep 8, 2023

Summary

Improve LocalizationProtocol to ease usage of more types of localization stores (not that Stores) for supplying localizations to disnake.

What is the feature request for?

The core library

The Problem

First, LocalizationProtocol requires implementors to build localization dicts on startup, but not all localization systems have all of the available localizations "at hand" (databases or on-demand loaders).

Secondly, it requires implementors to examine available languages themselves, forcing to use API in form of (key) -> { locale: l10n }, while most external localization systems use an API of form of (key, locale) -> l10n.

If not resolved by the programmer of LocalizationProtocol's implementation, second problem expands to the translator teams, because humans think in terms of (key, locale) -> l10n too. Let's imagine i'm a translator from source language (english) to russian. What i usually do is (abstractly): choose my locale (russian), choose the key to localize, and provide localization for it. Doesn't seem any good if i was forced to choose a key and then localize it for all locales, most of which i likely don't know. (a bit of drama, i know)

The Ideal Solution

Both problems can be resolved by changing LocalizationProtocol's .get() to be (key, locale) -> l10n instead, and (of course) updating all internal systems to use it. Not sure yet if this can be done in a compatible manner in regard to LocalizationProtocol implementors, but existing users of the default LocalizationStore will not be affected.

The Current Solution

"Problems" described above are (mostly) minor inconveniences, and can be worked around without relatively much hassle.

Additional Context

Related #1103

I am willing to submit a PR for this.

@elenakrittik elenakrittik added the feature request Request for a new feature label Sep 8, 2023
@shiftinv shiftinv added the t: refactor/typing/lint Refactors, typing changes and/or linting changes label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature t: refactor/typing/lint Refactors, typing changes and/or linting changes
Projects
None yet
Development

No branches or pull requests

2 participants