Closed deezee30 closed 1 year ago
@deezee30 Hmmm, I would advise against relying solely on Jiffy's locales. In terms of design, it is better to maintain your own list of locales that you can provide to your users. This approach gives you complete control and avoids excessive dependence on Jiffy.
By managing your own locales, you can customize the options to fit your specific needs, ensuring a more tailored and controlled experience for your users.
So in short, having your own list of supported locales is the best approach in my opinion
What do you think?
@jama5262 Completely agree with you. And that's what we are currently doing.
However, our own supported locales differ to Jiffy's. But when a user switches a locale within the app, we would like to configure Jiffy to change its locale too to keep it consistent. The issue lies in the fact that the chosen locale may not be supported by Jiffy. That's why we try to match the next closest locale based on what Jiffy does support.
Sorry for not being clear enough the first time.
Hmm, ok 👍 , I will add getAllAvailableLocales()
function back to Jiffy, will update when it's fully released, won't be long
Thanks for all your great work :)
This feature is now available and published in release https://github.com/jama5262/jiffy/releases/tag/v6.2.0
Is your feature request related to a problem? Please describe.
Since
6.0.0
, there is currently no way (as far as I know) to obtain which locales are supported by Jiffy. Prior to6.0.0
, I've regularly usedJiffy.getAllAvailableLocales()
to find and match the closest locale to the one currently chosen by the user. Some locale codes include or lack a region associated with the language. In a hypothetical scenario these regions (as well as the language) can be custom ones or not included in the locale code standards. Additionally, Jiffy does not support all languages and corresponding regions codes. My solution was to scan through available locales and match, in priority, a user's selected locale exactly to one supported by Jiffy. If not found, then match a language without the region. If not found, then match a language with a different region. If still not found, match a default locale that is definitely supported by both. It worked very well. Now, there is no functionality to do this anymore. In addition, Jiffy usesen_US
as a default locale if it wasn't found throughsetLocale
or other means which may not be desirable if it cannot be configured or at least checked for compatibility prior to callingsetLocale
.Describe the solution you'd like
Possible simple solutions:
Rename field
_availableLocales
toavailableLocales
inavailable_locales.dart
and make some method or field a part ofjiffy.dart
or otherwise, that acts as a wrapper toavailableLocales
, which could return just the keys of available locales:_availableLocales
toavailableLocales
inavailable_locales.dart
, makeavailableLocales
immutable, and include it in exports injiffy.dart
.Describe alternatives you've considered
Currently, I have to resort to making my own list of supported Jiffy locales separately to which locales my app fundamentally supports, based on
available_locales.dart
and update it manually between Jiffy versions, which is not ideal.Additional context
Not required.