Question

When I use this line to set Locale for Japanese it works just fine.

tts.setLanguage(Locale.JAPANESE);

When I substitute FRENCH, GERMAN, ITALIAN and CHINESE it also works.

When I substitute SPANISH, RUSSIAN or HINDI Eclipse tells me "SPANISH cannot be resolved or is not a field" [fill in for the other languages].

I am told Android does provide support for these languages, so how is it possible I do not find them?

Était-ce utile?

La solution

According to the documentation the Locale object has no constant for spanish defined. You can try to use this (not tested):

Locale locale = new Locale("es", "ES");
tts.setLanguage(locale);

But keep this note in mind (also from the Locale documentation):

It is also a mistake to assume that all devices have the same locales available. A device sold in the US will almost certainly support en_US and es_US, but not necessarily any locales with the same language but different countries (such as en_GB or es_ES), nor any locales for other languages (such as de_DE). The opposite may well be true for a device sold in Europe.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top