Chromium Code Reviews| Index: third_party/libaddressinput/chromium/cpp/src/address_data.cc |
| diff --git a/third_party/libaddressinput/chromium/cpp/src/address_data.cc b/third_party/libaddressinput/chromium/cpp/src/address_data.cc |
| index 51d36c6d9d63153296da075856c3cfe536f09cce..6bc74afa6fee24cc8d10a1f5feb22ae39382f24e 100644 |
| --- a/third_party/libaddressinput/chromium/cpp/src/address_data.cc |
| +++ b/third_party/libaddressinput/chromium/cpp/src/address_data.cc |
| @@ -22,6 +22,7 @@ |
| #include <string> |
| #include <vector> |
| +#include "normalize_language_code.h" |
| #include "region_data_constants.h" |
| #include "rule.h" |
| @@ -65,7 +66,15 @@ void AddressData::FormatForDisplay(std::vector<std::string>* lines) const { |
| rule.CopyFrom(Rule::GetDefault()); |
| rule.ParseSerializedRule(RegionDataConstants::GetRegionData(country_code)); |
| - const std::vector<std::vector<FormatElement> >& format = rule.GetFormat(); |
| + std::string norm_address_lang = NormalizeLanguageCode(language_code); |
| + std::string norm_rule_lang = NormalizeLanguageCode(rule.GetLanguage()); |
|
Evan Stade
2014/03/21 23:44:54
nit: I would delete the norm_ part of each of thes
please use gerrit instead
2014/03/22 01:34:30
Done.
|
| + |
| + const std::vector<std::vector<FormatElement> >& latin_format = |
| + rule.GetLatinFormat(); |
| + const std::vector<std::vector<FormatElement> >& format = |
| + norm_address_lang != norm_rule_lang && !latin_format.empty() |
| + ? latin_format : rule.GetFormat(); |
| + |
| for (size_t i = 0; i < format.size(); ++i) { |
| std::string line; |
| for (size_t j = 0; j < format[i].size(); ++j) { |
| @@ -107,28 +116,5 @@ void AddressData::SetFieldValue(AddressField field, const std::string& value) { |
| } |
| } |
| -const std::string& AddressData::GuessLanguageCode() const { |
| - Rule rule; |
| - rule.CopyFrom(Rule::GetDefault()); |
| - if (!rule.ParseSerializedRule( |
| - RegionDataConstants::GetRegionData(country_code))) { |
| - return language_code; |
| - } |
| - |
| - std::vector<std::string>::const_iterator lang_it = |
| - std::find(rule.GetLanguages().begin(), |
| - rule.GetLanguages().end(), |
| - language_code); |
| - if (lang_it != rule.GetLanguages().end()) { |
| - return *lang_it; |
| - } |
| - |
| - if (!rule.GetLanguage().empty()) { |
| - return rule.GetLanguage(); |
| - } |
| - |
| - return language_code; |
| -} |
| - |
| } // namespace addressinput |
| } // namespace i18n |