dlutton / flutter_tts

Flutter Text to Speech package
MIT License
582 stars 241 forks source link

getLanguages() data formatting #304

Open CodyBontecou opened 2 years ago

CodyBontecou commented 2 years ago

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.

dlutton commented 2 years ago

@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.

CodyBontecou commented 2 years ago

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??

dlutton commented 2 years ago

@CodyBontecou yes they do

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