diff --git a/src/internationalization/PhutilLocale.php b/src/internationalization/PhutilLocale.php index 3ef2524e..5ed03a92 100644 --- a/src/internationalization/PhutilLocale.php +++ b/src/internationalization/PhutilLocale.php @@ -30,11 +30,14 @@ abstract class PhutilLocale extends Phobject { * 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 index 2c1ffbea..259ed541 100644 --- a/src/internationalization/locales/PhutilPortugueseBrazilLocale.php +++ b/src/internationalization/locales/PhutilPortugueseBrazilLocale.php @@ -13,4 +13,13 @@ final class PhutilPortugueseBrazilLocale extends PhutilLocale { 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 index f893b77f..f5a9eb71 100644 --- a/src/internationalization/locales/PhutilPortuguesePortugalLocale.php +++ b/src/internationalization/locales/PhutilPortuguesePortugalLocale.php @@ -13,4 +13,14 @@ final class PhutilPortuguesePortugalLocale extends PhutilLocale { 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 index 6b0c709b..4f763323 100644 --- a/src/internationalization/locales/PhutilSimplifiedChineseLocale.php +++ b/src/internationalization/locales/PhutilSimplifiedChineseLocale.php @@ -13,4 +13,13 @@ final class PhutilSimplifiedChineseLocale extends PhutilLocale { 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 index f8879506..19ca3edb 100644 --- a/src/internationalization/locales/PhutilTraditionalChineseLocale.php +++ b/src/internationalization/locales/PhutilTraditionalChineseLocale.php @@ -13,4 +13,8 @@ final class PhutilTraditionalChineseLocale extends PhutilLocale { return pht('Chinese (Traditional)'); } + public function getFallbackLocaleCode() { + return 'zh_Hans'; + } + } diff --git a/src/internationalization/locales/PhutilUSEnglishLocale.php b/src/internationalization/locales/PhutilUSEnglishLocale.php index ef1633ed..1bd7430c 100644 --- a/src/internationalization/locales/PhutilUSEnglishLocale.php +++ b/src/internationalization/locales/PhutilUSEnglishLocale.php @@ -13,4 +13,10 @@ final class PhutilUSEnglishLocale extends PhutilLocale { return pht('English (US)'); } + public function getFallbackLocaleCode() { + // The default fallback is en_US, explicitly return null here + // to avoid a fallback loop + return null; + } + }