flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

getLanguages() data formatting

Open CodyBontecou opened this issue 2 years ago • 3 comments

I'm curious if there is a way to get the language to provide more than the locale id.

When printing the data returned from getLanguages, it returns a list of locale codes formatted like so:

[ru-RU, en-US, es-ES, ... ]

Is there a built-in way to get the name associated with the locale id? I want to display English - US rather than en-US.

CodyBontecou avatar Jan 12 '22 01:01 CodyBontecou

@CodyBontecou Is this for Android? I easiest thing to do here without introducing a breaking change is to create a getDisplayCountry() method which calls it against the locale. I'll see if there is something similar on iOS.

dlutton avatar Jan 12 '22 01:01 dlutton

For now, it's Android but I'd prefer a universal solution if possible.

Do the languages get returned as a Locale type on Android??

CodyBontecou avatar Jan 12 '22 02:01 CodyBontecou

@CodyBontecou yes they do

for (Locale locale : tts.getAvailableLanguages()) {
          locales.add(locale.toLanguageTag());
        }

dlutton avatar Jan 13 '22 19:01 dlutton