Skip to content

Allow the selection for certain locales  #4

@elPeiretti

Description

@elPeiretti

Feature proposal

Based on @mlopezFC 's comment on #3 "It would be great to be able to only allow the selection for certain locales / countries".

What ideas come to your minds about it?

Currently, the addon is limited by the flag-icons package (which provides the flag icons). It renders the flags based on ISO 3166-1-alpha-2 (a 2 letter country code). Because of this, all the supported locales by the addons are:

  public static List<Locale> getAvailableSupportedLocales() {
    return Arrays.stream(Locale.getAvailableLocales()).filter(loc -> loc.getCountry().length() == 2)
        .toList();
  }

Maybe it would be a good option to have a helper class or static methods to build only supported locales. Or, we could simply allow the developer to set the locales that they want like:

List<Locale> myDesiredLocales; // list with some locales

LocaleComboBox myCombo = new LocaleComboBox(myDesiredLocales);
// or
myCombo.setItems(myDesiredLocales);

The issue with this approach is that it would be possible to add unsupported locales (for which the flags won't show)

So, i'm pretty unsure about it 🤔. Let me know what you think.

Describe solution expectations

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions