meikidd / locale-code

locale code based on ISO-639-1 and ISO-3166-1
Other
36 stars 5 forks source link

Access ISO-639-1 language code without country code #2

Closed Bhavesh-Radadiya closed 6 years ago

Bhavesh-Radadiya commented 6 years ago

Add functionality to access ISO-639-1 language code with or without the country code.

meikidd commented 6 years ago

This package provide utils for "locale code" with {language code}-{country code} format.

The method getLanguageCode extract the "language code" from the given "locale code", if you already have your "language code" you don't need this method. And also getLanguageName,getLanguages...

In addition, "locale code" is composed by "language code" and "country code", if you need to deal with "language code" or "country code" you may try iso-639-1 / iso-3166-1-alpha-2

Bhavesh-Radadiya commented 6 years ago

The user will fetch language code from a device, so he has language code with/without the country code. To handle this situation, he needs two deferent libraries. I edit this library to avoid this situation. It supports language code with/without the country code.

meikidd commented 6 years ago

To comply with the SRP(Single responsibility principle), this package only focus on dealing with the locale-code(with country code). And a few system dependent on this feature, they judge codes without country code are invalid values. Maybe we need a new package to carry your case.