intl_phone_field icon indicating copy to clipboard operation
intl_phone_field copied to clipboard

Country name doesn`t find the correct name translation for some countries

Open adilsonjuniordev opened this issue 1 year ago • 7 comments

Country name does not find the correct name translation for some countries because of the toLowerCase() method applied to the languageCode string.

"pt_BR" "sr-Cyrl" "sr-Latn" "zh_TW"

In file intl_phone_field.dart on (line 355), there is a toLowerCase() method being applied to the String languageCode, which is causing failure when searching for the translation of names for these mentioned countries.


SOLUTION 1

The solution could be to remove this toLowerCase() method.

SOLUTION BELOW:

Future<void> _changeCountry() async {
    filteredCountries = _countryList;
    await showDialog(
      context: context,
      useRootNavigator: false,
      builder: (context) => StatefulBuilder(
        builder: (ctx, setState) => CountryPickerDialog(
          languageCode: widget.languageCode,
          style: widget.pickerDialogStyle,
          filteredCountries: filteredCountries,
          searchText: widget.searchText,
          countryList: _countryList,
          selectedCountry: _selectedCountry,
          onCountryChanged: (Country country) {
            _selectedCountry = country;
            widget.onCountryChanged?.call(country);
            setState(() {});
          },
        ),
      ),
    );
    if (mounted) setState(() {});
  }

SOLUTION 2

In the countries.dart file, we can rename all country map keys to lowercase values by default, as in the example below:

"pt_br" "sr_cyrl" "sr_latn" "zh_tw"


CONCLUSION

We need these corrections, because due to this bug, we are unable to use the package in Brazil.

Thanks!!

adilsonjuniordev avatar Nov 16 '23 18:11 adilsonjuniordev

I made a pull request, if you agree you can merge it, if not, tell me and I can contribute in some other way.

Thanks!

adilsonjuniordev avatar Nov 16 '23 18:11 adilsonjuniordev

@all-contributors please add @adilsonjuniordev for code

adilsonjuniordev avatar Nov 16 '23 19:11 adilsonjuniordev

@adilsonjuniordev

I've put up a pull request to add @adilsonjuniordev! :tada:

allcontributors[bot] avatar Nov 16 '23 19:11 allcontributors[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 5 days. If you believe this issue is still relevant, please comment to keep it open. Thank you for your contributions.

github-actions[bot] avatar Dec 17 '23 02:12 github-actions[bot]

Waiting..

adilsonjuniordev avatar Dec 19 '23 19:12 adilsonjuniordev

Waiting...

adilsonjuniordev avatar Jan 14 '24 17:01 adilsonjuniordev

Waiting....

adilsonjuniordev avatar Feb 01 '24 13:02 adilsonjuniordev