Loading include/androidfw/ResourceTypes.h +6 −0 Original line number Diff line number Diff line Loading @@ -1195,6 +1195,12 @@ struct ResTable_config // Example: en-US, en-Latn-US, en-POSIX. void getBcp47Locale(char* out) const; // Append to str the resource-qualifer string representation of the // locale component of this Config. If the locale is only country // and language, it will look like en-rUS. If it has scripts and // variants, it will be a modified bcp47 tag: b+en+Latn+US. void appendDirLocale(String8& str) const; // Sets the values of language, region, script and variant to the // well formed BCP-47 locale contained in |in|. The input locale is // assumed to be valid and no validation is performed. Loading libs/androidfw/ResourceTypes.cpp +53 −6 Original line number Diff line number Diff line Loading @@ -2550,6 +2550,58 @@ bool ResTable_config::match(const ResTable_config& settings) const { return true; } void ResTable_config::appendDirLocale(String8& out) const { if (!language[0]) { return; } if (!localeScript[0] && !localeVariant[0]) { // Legacy format. if (out.size() > 0) { out.append("-"); } char buf[4]; size_t len = unpackLanguage(buf); out.append(buf, len); if (country[0]) { out.append("-r"); len = unpackRegion(buf); out.append(buf, len); } return; } // We are writing the modified bcp47 tag. // It starts with 'b+' and uses '+' as a separator. if (out.size() > 0) { out.append("-"); } out.append("b+"); char buf[4]; size_t len = unpackLanguage(buf); out.append(buf, len); if (localeScript[0]) { out.append("+"); out.append(localeScript, sizeof(localeScript)); } if (country[0]) { out.append("+"); len = unpackRegion(buf); out.append(buf, len); } if (localeVariant[0]) { out.append("+"); out.append(localeVariant, sizeof(localeVariant)); } } void ResTable_config::getBcp47Locale(char str[RESTABLE_MAX_LOCALE_LEN]) const { memset(str, 0, RESTABLE_MAX_LOCALE_LEN); Loading Loading @@ -2650,12 +2702,7 @@ String8 ResTable_config::toString() const { res.appendFormat("mnc%d", dtohs(mnc)); } char localeStr[RESTABLE_MAX_LOCALE_LEN]; getBcp47Locale(localeStr); if (strlen(localeStr) > 0) { if (res.size() > 0) res.append("-"); res.append(localeStr); } appendDirLocale(res); if ((screenLayout&MASK_LAYOUTDIR) != 0) { if (res.size() > 0) res.append("-"); Loading tests/Split/res/values-b+fr+Latn+CA/strings.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <string name="test">Bonsoir!</string> </resources> tests/Split/res/values-fr-rCA/strings.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <string name="test">Bonjour</string> </resources> tools/aapt/AaptAssets.cpp +0 −27 Original line number Diff line number Diff line Loading @@ -367,33 +367,6 @@ int AaptLocaleValue::initFromDirName(const Vector<String8>& parts, const int sta return currentIndex; } String8 AaptLocaleValue::toDirName() const { String8 dirName(""); if (language[0]) { dirName += language; } else { return dirName; } if (script[0]) { dirName += "-s"; dirName += script; } if (region[0]) { dirName += "-r"; dirName += region; } if (variant[0]) { dirName += "-v"; dirName += variant; } return dirName; } void AaptLocaleValue::initFromResTable(const ResTable_config& config) { config.unpackLanguage(language); config.unpackRegion(region); Loading Loading
include/androidfw/ResourceTypes.h +6 −0 Original line number Diff line number Diff line Loading @@ -1195,6 +1195,12 @@ struct ResTable_config // Example: en-US, en-Latn-US, en-POSIX. void getBcp47Locale(char* out) const; // Append to str the resource-qualifer string representation of the // locale component of this Config. If the locale is only country // and language, it will look like en-rUS. If it has scripts and // variants, it will be a modified bcp47 tag: b+en+Latn+US. void appendDirLocale(String8& str) const; // Sets the values of language, region, script and variant to the // well formed BCP-47 locale contained in |in|. The input locale is // assumed to be valid and no validation is performed. Loading
libs/androidfw/ResourceTypes.cpp +53 −6 Original line number Diff line number Diff line Loading @@ -2550,6 +2550,58 @@ bool ResTable_config::match(const ResTable_config& settings) const { return true; } void ResTable_config::appendDirLocale(String8& out) const { if (!language[0]) { return; } if (!localeScript[0] && !localeVariant[0]) { // Legacy format. if (out.size() > 0) { out.append("-"); } char buf[4]; size_t len = unpackLanguage(buf); out.append(buf, len); if (country[0]) { out.append("-r"); len = unpackRegion(buf); out.append(buf, len); } return; } // We are writing the modified bcp47 tag. // It starts with 'b+' and uses '+' as a separator. if (out.size() > 0) { out.append("-"); } out.append("b+"); char buf[4]; size_t len = unpackLanguage(buf); out.append(buf, len); if (localeScript[0]) { out.append("+"); out.append(localeScript, sizeof(localeScript)); } if (country[0]) { out.append("+"); len = unpackRegion(buf); out.append(buf, len); } if (localeVariant[0]) { out.append("+"); out.append(localeVariant, sizeof(localeVariant)); } } void ResTable_config::getBcp47Locale(char str[RESTABLE_MAX_LOCALE_LEN]) const { memset(str, 0, RESTABLE_MAX_LOCALE_LEN); Loading Loading @@ -2650,12 +2702,7 @@ String8 ResTable_config::toString() const { res.appendFormat("mnc%d", dtohs(mnc)); } char localeStr[RESTABLE_MAX_LOCALE_LEN]; getBcp47Locale(localeStr); if (strlen(localeStr) > 0) { if (res.size() > 0) res.append("-"); res.append(localeStr); } appendDirLocale(res); if ((screenLayout&MASK_LAYOUTDIR) != 0) { if (res.size() > 0) res.append("-"); Loading
tests/Split/res/values-b+fr+Latn+CA/strings.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <string name="test">Bonsoir!</string> </resources>
tests/Split/res/values-fr-rCA/strings.xml 0 → 100644 +4 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <resources> <string name="test">Bonjour</string> </resources>
tools/aapt/AaptAssets.cpp +0 −27 Original line number Diff line number Diff line Loading @@ -367,33 +367,6 @@ int AaptLocaleValue::initFromDirName(const Vector<String8>& parts, const int sta return currentIndex; } String8 AaptLocaleValue::toDirName() const { String8 dirName(""); if (language[0]) { dirName += language; } else { return dirName; } if (script[0]) { dirName += "-s"; dirName += script; } if (region[0]) { dirName += "-r"; dirName += region; } if (variant[0]) { dirName += "-v"; dirName += variant; } return dirName; } void AaptLocaleValue::initFromResTable(const ResTable_config& config) { config.unpackLanguage(language); config.unpackRegion(region); Loading