Chromium Code Reviews| Index: chrome/renderer/translate_helper.cc |
| diff --git a/chrome/renderer/translate_helper.cc b/chrome/renderer/translate_helper.cc |
| index e2d23bf25baec9cc2e0073ddbbb04ff4a782ede6..382b60ce3eba7fe383f389d1a0d7f400c18c4237 100644 |
| --- a/chrome/renderer/translate_helper.cc |
| +++ b/chrome/renderer/translate_helper.cc |
| @@ -78,7 +78,21 @@ void TranslateHelper::PageCaptured(const string16& contents) { |
| language = language.substr(0, coma_index); |
| } |
| TrimWhitespaceASCII(language, TRIM_ALL, &language); |
| - language = StringToLowerASCII(language); |
| + |
| + // Underscores instead of dashes are a frequent mistake. |
| + size_t underscore_index = language.find('_'); |
| + if (underscore_index != std::string::npos) { |
| + language[underscore_index] = '-'; |
|
MAD
2012/11/06 18:00:20
No need for {} here...
bcwhite
2012/11/06 18:37:49
Doh! I am going to do that _every_ time!
Fixed.
|
| + } |
|
MAD
2012/11/06 18:00:20
Add a DCHECK that there are not other '_' in the s
bcwhite
2012/11/06 18:37:49
We're parsing user-supplied input here. Is crashi
MAD
2012/11/06 18:39:30
OK, fine...
|
| + |
| + // Change everything up to a dash to lower-case and everything after to upper. |
| + size_t dash_index = language.find('-'); |
| + if (dash_index != std::string::npos) { |
| + language = StringToLowerASCII(language.substr(0, dash_index)) + |
|
MAD
2012/11/06 18:00:20
Add a DCHECK that there are no other '-' in the st
bcwhite
2012/11/06 18:37:49
Same as above. I don't think it's a problem as ma
|
| + StringToUpperASCII(language.substr(dash_index)); |
| + } else { |
| + language = StringToLowerASCII(language); |
| + } |
| if (language.empty()) { |
| base::TimeTicks begin_time = base::TimeTicks::Now(); |