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

Introduce Locale enum #752

Closed
cieslarmichal opened this issue Jun 27, 2024 · 11 comments · Fixed by #826
Closed

Introduce Locale enum #752

cieslarmichal opened this issue Jun 27, 2024 · 11 comments · Fixed by #826
Assignees
Labels
help wanted Extra attention is needed high priority High priority

Comments

@cieslarmichal
Copy link
Owner

cieslarmichal commented Jun 27, 2024

Create locale enum like in faker.js

In this issue just create a enum type that contains all values below, for USA which uses english language it would be en_US value, so _

from values:

enum class PassportCountry
{
    France,
    Poland,
    Romania,
    Usa,
};

enum class SsnCountry
{
    England,
    France,
    Germany,
    India,
    Italy,
    Poland,
    Spain,
    Usa,
};

enum class Language
{
    Albanian,
    Belarusian,
    Croatian,
    Czech,
    Danish,
    Dutch,
    English,
    Estonian,
    Finnish,
    French,
    German,
    Greek,
    Hindi,
    Hungarian,
    Irish,
    Italian,
    Japanese,
    Korean,
    Latvian,
    Macedonian,
    Mandarin,
    Nepali,
    Norwegian,
    Polish,
    Portuguese,
    Romanian,
    Russian,
    Serbian,
    Slovak,
    Slovene,
    Spanish,
    Swedish,
    Turkish,
    Ukrainian,
};

enum class Country
{
    Albania,
    Argentina,
    Australia,
    Austria,
    Azerbaijan,
    Belarus,
    Belgium,
    Bosnia,
    Brazil,
    Bulgaria,
    Canada,
    China,
    Croatia,
    Czech,
    Denmark,
    England,
    Estonia,
    Finland,
    France,
    Germany,
    Ghana,
    Greece,
    Hungary,
    Iceland,
    India,
    Iran,
    Ireland,
    Israel,
    Italy,
    Japan,
    Kazakhstan,
    Korea,
    Latvia,
    Lebanon,
    Lithuania,
    Macedonia,
    Maldives,
    Malta,
    Mexico,
    Moldova,
    Monaco,
    Nepal,
    Netherlands,
    Norway,
    Palestine,
    Poland,
    Portugal,
    Romania,
    Russia,
    Serbia,
    Slovakia,
    Slovenia,
    SouthAfrica,
    Spain,
    Sweden,
    Switzerland,
    Syria,
    Turkey,
    Ukraine,
    Usa,
    Vietnam,
};
@cieslarmichal cieslarmichal added high priority High priority help wanted Extra attention is needed labels Jun 27, 2024
@AbdulTade
Copy link

Hi @cieslarmichal I want to work on this issue, can you please provide more context ?

@cieslarmichal
Copy link
Owner Author

hello, so instead of types that are specific for language, location we would like to combine them to have standardized enum param for all methods so user can just choose use Locale::en_US instead of couple of enum values like Country::Usa, Language::English, PassportCountry::Usa - it will be simplier to use it :)

with this issue just create a new enum, dont modify existing ones

@cieslarmichal
Copy link
Owner Author

locales like: https://docs.oracle.com/cd/E23824_01/html/E26033/glset.html

@AbdulTade
Copy link

hello, so instead of types that are specific for language, location we would like to combine them to have standardized enum param for all methods so user can just choose use Locale::en_US instead of couple of enum values like Country::Usa, Language::English, PassportCountry::Usa - it will be simplier to use it :)

with this issue just create a new enum, dont modify existing ones
.
Thank @cieslarmichal, Would proceed

@jackhwalters
Copy link
Contributor

If no one is working on this I can take it up.

@cieslarmichal
Copy link
Owner Author

Ok. Assigned

@jackhwalters
Copy link
Contributor

To be clear, do you want to end up with an enum that is the number of languages multiplied by the number of countries large? This would lead to severe code bloat and would not be easily maintainable. Why not combine PassportCountry, SsnCountry, and Country into one enum class called Country (representing duplicates once), and define and use a struct for both like so:

struct Locale {
    Language language;
    Country country;
};

@cieslarmichal
Copy link
Owner Author

Locale defines both country and language at once, it won't have countries x languages size because it uses country with language only when it has a meaning, couple examples:

  • for polish language: has only pl_PL because only polish language in Poland
  • german langauge: has many locales because there are couple of countries where there is a german language like Austria(de_AT), Germany(de_DE), Switzerland(de_CH) etc, so it doesnt define some random values like(de_EN)

Here is a reference for locales in Oracle docs: https://docs.oracle.com/cd/E23824_01/html/E26033/glset.html

Hope it will make sense now.

Also locales in faker.js: https://github.com/faker-js/faker/tree/next/src/locales

@cieslarmichal
Copy link
Owner Author

further work to be done: #825

@jackhwalters
Copy link
Contributor

Got it, in the interest of time how about we just scrape https://docs.oracle.com/cd/E23824_01/html/E26033/glset.html or https://github.com/faker-js/faker/tree/next/src/locales for locales?

@jackhwalters
Copy link
Contributor

Created PR for feedback #826.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed high priority High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants