ekwonye-richard / react-flags-select

Customizable svg flags select components for React Js
197 stars 121 forks source link

Showing multiple times the same flag for different locales #61

Closed zedtux closed 3 years ago

zedtux commented 4 years ago

I'm trying to so a language selector using this component but the issue is that for the same country, there are different languages, but only the last one is kept from the customLabels object.

Here is how I'm trying to use customLabels:

<ReactFlagsSelect
  countries={['BE', 'FR']}
  customLabels={{
    BE: 'FR',
    BE: 'NL',
    FR: 'FR'
  }}
/>

Would you mind to implement this use case please?


Adding another BE in the countries list helped a little bit:

<ReactFlagsSelect
  countries={['BE', 'BE', 'FR']}
  customLabels={{
    BE: 'FR',
    BE: 'NL',
    FR: 'FR'
  }}
/>

Screenshot 2020-10-26 at 16 23 28

zedtux commented 4 years ago

A better option would be to allow passing an array of string or an array of Object as countries and remove the customLabels:

<ReactFlagsSelect
  countries={[
    { BE: 'FR' },
    { BE: 'NL' },
    { FR: 'FR' }
  ]}
/>

It would cover the README.md example too:

<ReactFlagsSelect
  countries={[
    { US: 'EN-US' },
    { GB: 'EN-GB },
    { FR: 'FR' },
    { DE: 'DE' },
    { IT: 'IT' }
  ]}
/>
Filip785 commented 4 years ago

I'm looking for exactly the same thing. Another use case: some languages can be written in multiple alphabets, for example Serbian language can be written with both latin and cyrillic alphabets, thus this would be useful.

Hope this can be merged soon.

zedtux commented 4 years ago

Great to see that my work would help someone else ! 🤩

zedtux commented 4 years ago

@ekwonye-richard can you please have a look at the PR and give your input?

ekwonye-richard commented 3 years ago

Closing this following the closed PR