Cupertino localization step 1: add an English arb file (#29200)

This commit is contained in:
xster
2019-03-15 12:10:35 -07:00
committed by GitHub
parent 0067efca61
commit fa149eea9b
4 changed files with 107 additions and 4 deletions

View File

@@ -570,7 +570,7 @@ void processBundle(File file, { @required String localeString }) {
// Only pre-assume scriptCode if there is a country or script code to assume off of.
// When we assume scriptCode based on languageCode-only, we want this initial pass
// to use the un-assumed version as a base class.
LocaleInfo locale = LocaleInfo.fromString(localeString, assume: localeString.split('_').length > 1);
LocaleInfo locale = LocaleInfo.fromString(localeString, deriveScriptCode: localeString.split('_').length > 1);
// Allow overwrite if the existing data is assumed.
if (assumedLocales.contains(locale)) {
localeToResources[locale] = <String, String>{};
@@ -582,7 +582,7 @@ void processBundle(File file, { @required String localeString }) {
}
populateResources(locale);
// Add an assumed locale to default to when there is no info on scriptOnly locales.
locale = LocaleInfo.fromString(localeString, assume: true);
locale = LocaleInfo.fromString(localeString, deriveScriptCode: true);
if (locale.scriptCode != null) {
final LocaleInfo scriptLocale = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode);
if (!localeToResources.containsKey(scriptLocale)) {

View File

@@ -24,7 +24,10 @@ class LocaleInfo implements Comparable<LocaleInfo> {
/// and country is 2-3 characters and all uppercase.
///
/// 'language_COUNTRY' or 'language_script' are also valid. Missing fields will be null.
factory LocaleInfo.fromString(String locale, {bool assume = false}) {
///
/// When `deriveScriptCode` is true, if [scriptCode] was unspecified, it will
/// be derived from the [languageCode] and [countryCode] if possible.
factory LocaleInfo.fromString(String locale, { bool deriveScriptCode = false }) {
final List<String> codes = locale.split('_'); // [language, script, country]
assert(codes.isNotEmpty && codes.length < 4);
final String languageCode = codes[0];
@@ -49,7 +52,7 @@ class LocaleInfo implements Comparable<LocaleInfo> {
/// The basis of the assumptions here are based off of known usage of scripts
/// across various countries. For example, we know Taiwan uses traditional (Hant)
/// script, so it is safe to apply (Hant) to Taiwanese languages.
if (assume && scriptCode == null) {
if (deriveScriptCode && scriptCode == null) {
switch (languageCode) {
case 'zh': {
if (countryCode == null) {