Closed Crissium closed 1 year ago
Shall I close the original PR?
Shall I close the original PR?
Yes, please :)
Yes, I'll go along with that idea. I wrote this enum because I didn't know QLocale
class before (haven't done any i18n). QLocale::Country
is indeed very suitable here. So a big rewrite is in order now. But I've got plenty of spare time in hand.
And one more thing:
QString QOnlineTts::languageApiCode(QOnlineTranslator::Engine engine, QOnlineTranslator::Language lang)
{
switch (engine) {
case QOnlineTranslator::Google:
case QOnlineTranslator::Lingva: // Lingva is a frontend to Google Translate
if (lang != QOnlineTranslator::Auto) {
if (m_regionPreferences.contains(lang))
return regionCode(m_regionPreferences.value(lang));
else
return QOnlineTranslator::languageApiCode(engine, lang); // Google use the same codes for tts (except 'auto')
}
break;
Should we do a test here checking for DefaultRegion
like this:
if (m_regionPreferences.contains(lang) && m_regionPreferences.value(lang) != DefaultRegion)
// ...
This way DefaultRegion
will really default to the corresponding language code without the region specifier.
So a big rewrite is in order now. But I've got plenty of spare time in hand.
Nice to hear!
Should we do a test here checking for DefaultRegion like this:
What if we use QMap::value and pass QOnlineTranslator::languageApiCode
call as a default value (second argument)?
Oh, yes. Silly me. Just forgot QMap
has such a nice feature.
Sorry, just removed a review request. I have no idea how it got removed when I only re-requested a review.
@Crissium if you are interesting to see this feature in Crow soon, I would appreciate a PR :smile: Let me know if you are interested. Feel free to ask me any questions about it, I will walk you through the code base (it's small).
Yes, I am perfectly willing to contribute to Crow! I've got 10 days with few things to do.
Sorry, when I'm adding the region option to Crow, it turns out that the regionName
method duplicates the language name ("Bangla: Bangla (Bangladesh)" sounds stupid), which it shouldn't. I shall open a new PR and submit the fix. Sorry for the trouble :(
close #40
Example:
I get the list of supported regional voices from the official Google Translate Android app. Turns out that it is not very impressive.
If Google encounters an unsupported region code, it won't return error; instead, it defaults to the region-neutral language code.
PS: It is my first major contribution to others' repo. Please have the goodness to tell me if I have botched it and if there's anything improperly done (for example, breach of coding style)!