[android] Load TTS languages from core

Signed-off-by: Andrei Shkrob <github@shkrob.dev>
This commit is contained in:
Andrei Shkrob
2025-07-19 00:12:29 +02:00
committed by Konstantin Pastbin
parent 0a96a23ca0
commit ebc5370052
4 changed files with 95 additions and 139 deletions

View File

@@ -4,13 +4,29 @@
#include <string>
#include <utility>
// The list of languages which can be used by TTS.
// It shall be included in Android (jni) and iOS parts to get the languages list.
// TODO: Now it is used only on iOS.
// Manual sync with android/res/values/strings-tts.xml is needed.
#include "std/target_os.hpp"
namespace routing::turns::sound
{
/**
* @brief The list of languages which can be used by TTS (Text-To-Speech).
*
* Supported language identifiers follow the format:
* @code
* language[-COUNTRY][:internal_code]
* @endcode
*
* Where:
* - `language`: a two-letter ISO 639-1 language code (e.g., "en", "fr", "zh").
* - `COUNTRY`: optional two-letter ISO 3166-1 alpha-2 country code (e.g., "US", "CN", "TW").
* - `internal_code`: optional internal language code used by the TTS core.
* If not specified, `language` is used as the default.
*
* @note Special handling for Chinese:
* - `zh_TW`, `zh_MO`, and `zh_HK` are treated as `zh-Hant` (Traditional Chinese).
* - All other variants default to `zh-Hans` (Simplified Chinese).
*
*/
std::array<std::pair<std::string_view, std::string_view>, 40> constexpr kLanguageList =
{{
{"en", "English"},
@@ -18,8 +34,13 @@ std::array<std::pair<std::string_view, std::string_view>, 40> constexpr kLanguag
{"ca", "Català"},
{"da", "Dansk"},
{"de", "Deutsch"},
#ifdef OMIM_OS_ANDROID
{"es-ES:es", "Español"},
{"es-MX:es-MX", "Español (México)"},
#else
{"es", "Español"},
{"es-MX", "Español (México)"},
#endif
{"eu", "Euskara"},
{"fr", "Français"},
{"hr", "Hrvatski"},
@@ -29,8 +50,13 @@ std::array<std::pair<std::string_view, std::string_view>, 40> constexpr kLanguag
{"nl", "Nederlands"},
{"nb", "Norsk Bokmål"},
{"pl", "Polski"},
#ifdef OMIM_OS_ANDROID
{"pt-PT:pt", "Português"},
{"pt-BR:pt-BR", "Português (Brasil)"},
#else
{"pt", "Português"},
{"pt-BR", "Português (Brasil)"},
#endif
{"ro", "Română"},
{"sk", "Slovenčina"},
{"fi", "Suomi"},
@@ -49,8 +75,13 @@ std::array<std::pair<std::string_view, std::string_view>, 40> constexpr kLanguag
{"mr", "मराठी"},
{"hi", "हिंदी"},
{"th", "ไทย"},
#ifdef OMIM_OS_ANDROID
{"zh-CN:zh-Hans", "中文简体"},
{"zh-TW:zh-Hant", "中文繁體"},
#else
{"zh-Hans", "中文简体"},
{"zh-Hant", "中文繁體"},
#endif
{"ja", "日本語"},
{"ko", "한국어"},
}};