diff --git a/src/internationalization/PhutilLocale.php b/src/internationalization/PhutilLocale.php --- a/src/internationalization/PhutilLocale.php +++ b/src/internationalization/PhutilLocale.php @@ -30,11 +30,14 @@ * For locales like "English (Great Britain)", missing translations can be * sourced from "English (US)". * + * Languages with no other fallback use en_US because that's better + * than proto-English for untranslated strings. + * * @return string|null Locale code of fallback locale, or null if there is * no fallback locale. */ public function getFallbackLocaleCode() { - return null; + return 'en_US'; } diff --git a/src/internationalization/locales/PhutilPortugueseBrazilLocale.php b/src/internationalization/locales/PhutilPortugueseBrazilLocale.php --- a/src/internationalization/locales/PhutilPortugueseBrazilLocale.php +++ b/src/internationalization/locales/PhutilPortugueseBrazilLocale.php @@ -13,4 +13,13 @@ return pht('Portuguese (Brazil)'); } + public function getFallbackLocaleCode() { + // Phabricator does not support bidirectional + // fallbacks (pt_BR -> pt and pt -> pt_BR simultaneously) + // since Translatewiki calls pt_PT "Portugese" without a country + // it makes slightly more sense to fall back in this direction + // than the other one + return 'pt_PT'; + } + } diff --git a/src/internationalization/locales/PhutilPortuguesePortugalLocale.php b/src/internationalization/locales/PhutilPortuguesePortugalLocale.php --- a/src/internationalization/locales/PhutilPortuguesePortugalLocale.php +++ b/src/internationalization/locales/PhutilPortuguesePortugalLocale.php @@ -13,4 +13,14 @@ return pht('Portuguese (Portugal)'); } + public function getFallbackLocaleCode() { + // Ideally this would be pt_BR but Phabricator does not support + // bidirectional fallbacks (pt_BR -> pt and pt -> pt_BR simultaneously) + // since Translatewiki calls pt_PT "Portugese" without a country + // it makes slightly more sense to fall back in the other direction + // In the mean time return `en_US` so users don't see Proto-English + // unncecessarily + return 'en_US'; + } + } diff --git a/src/internationalization/locales/PhutilSimplifiedChineseLocale.php b/src/internationalization/locales/PhutilSimplifiedChineseLocale.php --- a/src/internationalization/locales/PhutilSimplifiedChineseLocale.php +++ b/src/internationalization/locales/PhutilSimplifiedChineseLocale.php @@ -13,4 +13,13 @@ return pht('Chinese (Simplified)'); } + public function getFallbackLocaleCode() { + // Ideally this would be zh_Hant but Phabricator does not support + // bidirectional fallbacks + // (zh_Hant -> zh_Hans and zh_Hans -> zh_Hant simultaneously) + // arbitrarily choose to fall back in the other direction instead + // In the mean time return `en_US` so users don't see Proto-English + return 'en_US'; + } + } diff --git a/src/internationalization/locales/PhutilTraditionalChineseLocale.php b/src/internationalization/locales/PhutilTraditionalChineseLocale.php --- a/src/internationalization/locales/PhutilTraditionalChineseLocale.php +++ b/src/internationalization/locales/PhutilTraditionalChineseLocale.php @@ -13,4 +13,8 @@ return pht('Chinese (Traditional)'); } + public function getFallbackLocaleCode() { + return 'zh_Hans'; + } + } diff --git a/src/internationalization/locales/PhutilUSEnglishLocale.php b/src/internationalization/locales/PhutilUSEnglishLocale.php --- a/src/internationalization/locales/PhutilUSEnglishLocale.php +++ b/src/internationalization/locales/PhutilUSEnglishLocale.php @@ -13,4 +13,10 @@ return pht('English (US)'); } + public function getFallbackLocaleCode() { + // The default fallback is en_US, explicitly return null here + // to avoid a fallback loop + return null; + } + }