Translate the original text to the target language using i18n. :param bundle_id: The bundle ID. :param original: The original text. :param lang: The target language. :return: text in the target language.
(
bundle_id: str,
original: str,
lang: str,
)
| 159 | |
| 160 | |
| 161 | def i18n_text( |
| 162 | bundle_id: str, |
| 163 | original: str, |
| 164 | lang: str, |
| 165 | ): |
| 166 | """ |
| 167 | Translate the original text to the target language using i18n. |
| 168 | |
| 169 | :param bundle_id: The bundle ID. |
| 170 | :param original: The original text. |
| 171 | :param lang: The target language. |
| 172 | :return: text in the target language. |
| 173 | """ |
| 174 | global _i18n_dict |
| 175 | if original.startswith("i18n:"): |
| 176 | key = original[5:] |
| 177 | i18n_key = f"{bundle_id}:{lang}:{key}" |
| 178 | return _i18n_dict.get(i18n_key, "") or _i18n_dict.get(f"{bundle_id}:{CONFIG.DEFAULT_LANG}:{key}", "") |
| 179 | |
| 180 | return original |
no test coverage detected