Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a list when trying to translate a country name #15

Open
tomsun opened this issue Aug 25, 2023 · 2 comments
Open

Getting a list when trying to translate a country name #15

tomsun opened this issue Aug 25, 2023 · 2 comments

Comments

@tomsun
Copy link

tomsun commented Aug 25, 2023

This works as expected

void getEnglishCountryName(String countryCode) async {
  final localizations = CountryLocalizations(Locale('en'));
  await localizations.load();
  String? countryName = localizations.translate(countryCode);
  print(countryName);  // This should print "Sweden" for "SE"
}

// Using the function
getEnglishCountryName('SE');

But getEnglishCountryName('US') prints "[United States of America, USA]" instead of a single human-readable name, perhaps due to toString() being used here:

return MapEntry(key, value.toString());

@amin79
Copy link

amin79 commented Oct 13, 2023

Hi. Did you find any solutions? I have the same problem.

@tomsun
Copy link
Author

tomsun commented Oct 13, 2023

@amin79 while waiting for a reaction from the maintainer(s), I'm using this patch, which goes for the first value in the list and ignores the others tomsun@a2ceef5

(Note that my fork is a bit behind @chandrabezzo 's repo - I'm using the final snapshot from @imtoori + an upgrade of modal_bottom_sheet + this fix. But the patch probably fits onto @chandrabezzo 's version aswell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants