Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc

Issue 134903003: libaddressinput string translations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_browser_ui.gypi » ('j') | chrome/chrome_browser_ui.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "components/autofill/core/browser/field_types.h" 10 #include "components/autofill/core/browser/field_types.h"
11 #include "grit/component_strings.h" 11 #include "grit/component_strings.h"
12 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h" 12 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_field.h"
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h" 13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h"
14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h" 14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h"
15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h"
16 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
17 16
17 #include "grit/libaddressinput_strings.h"
Mark Mentovai 2014/01/13 16:43:36 Why not in-line with the #includes above?
Evan Stade 2014/01/13 23:36:07 This include is not necessary at all, it was only
18
18 namespace autofill { 19 namespace autofill {
19 namespace i18ninput { 20 namespace i18ninput {
20 21
21 namespace { 22 namespace {
22 23
23 using i18n::addressinput::AddressField; 24 using i18n::addressinput::AddressField;
24 using i18n::addressinput::AddressUiComponent; 25 using i18n::addressinput::AddressUiComponent;
25 26
26 ServerFieldType GetServerType(AddressField address_field, bool billing) { 27 ServerFieldType GetServerType(AddressField address_field, bool billing) {
27 switch (address_field) { 28 switch (address_field) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } // namespace 60 } // namespace
60 61
61 bool Enabled() { 62 bool Enabled() {
62 CommandLine* command_line = CommandLine::ForCurrentProcess(); 63 CommandLine* command_line = CommandLine::ForCurrentProcess();
63 return command_line->HasSwitch(::switches::kEnableAutofillAddressI18n); 64 return command_line->HasSwitch(::switches::kEnableAutofillAddressI18n);
64 } 65 }
65 66
66 void BuildAddressInputs(common::AddressType address_type, 67 void BuildAddressInputs(common::AddressType address_type,
67 const std::string& country_code, 68 const std::string& country_code,
68 DetailInputs* inputs) { 69 DetailInputs* inputs) {
69 i18n::addressinput::Localization localization; 70 NOTIMPLEMENTED() << " SOME STRING CALLED IDS_LIBADDRESSINPUT_I18N_DEPENDENT_LO CALITY_LABEL is ID " << IDS_LIBADDRESSINPUT_I18N_DEPENDENT_LOCALITY_LABEL << " a nd string is " << l10n_util::GetStringUTF16(IDS_LIBADDRESSINPUT_I18N_DEPENDENT_L OCALITY_LABEL);
please use gerrit instead 2014/01/13 18:50:13 Is this a debug log?
Evan Stade 2014/01/13 23:36:07 yes. This is a concrete example of this CL not bei
70 // TODO(dbeam): figure out how to include libaddressinput's translations into 71
71 // some .pak file so I can call |SetGetter(&l10n_util::GetStringUTF8)| here.
72 std::vector<AddressUiComponent> components( 72 std::vector<AddressUiComponent> components(
73 i18n::addressinput::BuildComponents(country_code, localization)); 73 i18n::addressinput::BuildComponents(country_code));
74 74
75 const bool billing = address_type == common::ADDRESS_TYPE_BILLING; 75 const bool billing = address_type == common::ADDRESS_TYPE_BILLING;
76 76
77 for (size_t i = 0; i < components.size(); ++i) { 77 for (size_t i = 0; i < components.size(); ++i) {
78 const AddressUiComponent& component = components[i]; 78 const AddressUiComponent& component = components[i];
79 if (component.field == i18n::addressinput::ORGANIZATION) { 79 if (component.field == i18n::addressinput::ORGANIZATION) {
80 // TODO(dbeam): figure out when we actually need this. 80 // TODO(dbeam): figure out when we actually need this.
81 continue; 81 continue;
82 } 82 }
83 83
84 ServerFieldType server_type = GetServerType(component.field, billing); 84 ServerFieldType server_type = GetServerType(component.field, billing);
85 DetailInput::Length length = LengthFromHint(component.length_hint); 85 DetailInput::Length length = LengthFromHint(component.length_hint);
86 base::string16 placeholder = base::UTF8ToUTF16(component.name); 86 base::string16 placeholder = l10n_util::GetStringUTF16(component.name_id);
87 DetailInput input = { length, server_type, placeholder }; 87 DetailInput input = { length, server_type, placeholder };
88 inputs->push_back(input); 88 inputs->push_back(input);
89 89
90 if (component.field == i18n::addressinput::STREET_ADDRESS) { 90 if (component.field == i18n::addressinput::STREET_ADDRESS) {
91 // TODO(dbeam): support more than 2 address lines. http://crbug.com/324889 91 // TODO(dbeam): support more than 2 address lines. http://crbug.com/324889
92 ServerFieldType server_type = 92 ServerFieldType server_type =
93 billing ? ADDRESS_BILLING_LINE2 : ADDRESS_HOME_LINE2; 93 billing ? ADDRESS_BILLING_LINE2 : ADDRESS_HOME_LINE2;
94 base::string16 placeholder = base::UTF8ToUTF16(component.name); 94 base::string16 placeholder = l10n_util::GetStringUTF16(component.name_id);
95 DetailInput input = { length, server_type, placeholder }; 95 DetailInput input = { length, server_type, placeholder };
96 inputs->push_back(input); 96 inputs->push_back(input);
97 } 97 }
98 } 98 }
99 99
100 ServerFieldType server_type = 100 ServerFieldType server_type =
101 billing ? ADDRESS_BILLING_COUNTRY : ADDRESS_HOME_COUNTRY; 101 billing ? ADDRESS_BILLING_COUNTRY : ADDRESS_HOME_COUNTRY;
102 base::string16 placeholder_text = 102 base::string16 placeholder_text =
103 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_COUNTRY); 103 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_COUNTRY);
104 // TODO(dbeam): unhide so users can switch countries. http://crbug.com/331544 104 // TODO(dbeam): unhide so users can switch countries. http://crbug.com/331544
105 DetailInput input = { DetailInput::NONE, server_type, placeholder_text }; 105 DetailInput input = { DetailInput::NONE, server_type, placeholder_text };
106 inputs->push_back(input); 106 inputs->push_back(input);
107 } 107 }
108 108
109 } // namespace i18ninput 109 } // namespace i18ninput
110 } // namespace autofill 110 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_browser_ui.gypi » ('j') | chrome/chrome_browser_ui.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698