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

feat!(model): typed locales #2068

Draft
wants to merge 2 commits into
base: zeyla/feat-model-rework-enums
Choose a base branch
from

Conversation

zeylahellyer
Copy link
Member

Adds a typed Locale struct with associated constants for all known values, replacing the Strings used in the codebase. The Locale type has two methods of note: english_name and native_name.

These values are taken from the Discord documentation: https://discord.com/developers/docs/reference#locales

This PR is meant to show how the new raw value representation introduced in PR #2045 looks when "typing" a value. This was previously left to the user to know what localizations might exist and to ensure a typo isn't made. This Locale type is still functionally a string in all but name (literally, as it implements the same traits and derefs in the same way String does), but it contains methods and the known values registered by Twilight as "sugar" on top of it.

Adds a typed Locale struct with associated constants for all known
values, replacing the Strings used in the codebase. The Locale type has
two methods of note: `english_name` and `native_name`.

These values are taken from the Discord documentation:
<https://discord.com/developers/docs/reference#locales>

This PR is meant to show how the new raw value representation introduced
in PR #2045 looks when "typing" a value. This was previously left to the
user to know what localizations might exist and to ensure a typo isn't
made. This `Locale` type is still functionally a string in all but name
(literally, as it implements the same traits and derefs in the same way
String does), but it contains methods and the known values registered by
Twilight as "sugar" on top of it.
@zeylahellyer zeylahellyer added w-do-not-merge PR is blocked or deferred w-unapproved Proposal for change has *not* been approved by @twilight-rs/core. labels Jan 15, 2023
@github-actions github-actions bot added c-cache Affects the cache crate c-http Affects the http crate c-model Affects the model crate c-standby Affects the standby crate c-util Affects the util crate c-validate Affects the validate crate labels Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-cache Affects the cache crate c-http Affects the http crate c-model Affects the model crate c-standby Affects the standby crate c-util Affects the util crate c-validate Affects the validate crate w-do-not-merge PR is blocked or deferred w-unapproved Proposal for change has *not* been approved by @twilight-rs/core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant