OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/l10n/l10n_util.h" | 5 #include "ui/base/l10n/l10n_util.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <glib/gutils.h> | 8 #include <glib/gutils.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <cstdlib> | 12 #include <cstdlib> |
13 #include <iterator> | 13 #include <iterator> |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/i18n/file_util_icu.h" | 17 #include "base/i18n/file_util_icu.h" |
18 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/stringprintf.h" |
21 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
22 #include "base/string_split.h" | 23 #include "base/string_split.h" |
23 #include "base/sys_string_conversions.h" | 24 #include "base/sys_string_conversions.h" |
24 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "ui/base/l10n/l10n_util_collator.h" | 27 #include "ui/base/l10n/l10n_util_collator.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/base/ui_base_paths.h" | 29 #include "ui/base/ui_base_paths.h" |
29 #include "unicode/rbbi.h" | 30 #include "unicode/rbbi.h" |
30 #include "unicode/uloc.h" | 31 #include "unicode/uloc.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // silently fail to insert one. If |offsets| is non-NULL, then don't do this | 596 // silently fail to insert one. If |offsets| is non-NULL, then don't do this |
596 // check as the code may simply want to find the placeholders rather than | 597 // check as the code may simply want to find the placeholders rather than |
597 // actually replacing them. | 598 // actually replacing them. |
598 if (!offsets) { | 599 if (!offsets) { |
599 std::string utf8_string = UTF16ToUTF8(format_string); | 600 std::string utf8_string = UTF16ToUTF8(format_string); |
600 | 601 |
601 // $9 is the highest allowed placeholder. | 602 // $9 is the highest allowed placeholder. |
602 for (size_t i = 0; i < 9; ++i) { | 603 for (size_t i = 0; i < 9; ++i) { |
603 bool placeholder_should_exist = replacements.size() > i; | 604 bool placeholder_should_exist = replacements.size() > i; |
604 | 605 |
605 std::string placeholder = StringPrintf("$%d", static_cast<int>(i + 1)); | 606 std::string placeholder = |
| 607 base::StringPrintf("$%d", static_cast<int>(i + 1)); |
606 size_t pos = utf8_string.find(placeholder.c_str()); | 608 size_t pos = utf8_string.find(placeholder.c_str()); |
607 if (placeholder_should_exist) { | 609 if (placeholder_should_exist) { |
608 DCHECK_NE(std::string::npos, pos) << | 610 DCHECK_NE(std::string::npos, pos) << |
609 " Didn't find a " << placeholder << " placeholder in " << | 611 " Didn't find a " << placeholder << " placeholder in " << |
610 utf8_string; | 612 utf8_string; |
611 } else { | 613 } else { |
612 DCHECK_EQ(std::string::npos, pos) << | 614 DCHECK_EQ(std::string::npos, pos) << |
613 " Unexpectedly found a " << placeholder << " placeholder in " << | 615 " Unexpectedly found a " << placeholder << " placeholder in " << |
614 utf8_string; | 616 utf8_string; |
615 } | 617 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { | 851 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { |
850 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) | 852 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) |
851 // TODO(jungshik) : Put them at the of the list with language codes | 853 // TODO(jungshik) : Put them at the of the list with language codes |
852 // enclosed by brackets instead of skipping. | 854 // enclosed by brackets instead of skipping. |
853 continue; | 855 continue; |
854 locale_codes->push_back(kAcceptLanguageList[i]); | 856 locale_codes->push_back(kAcceptLanguageList[i]); |
855 } | 857 } |
856 } | 858 } |
857 | 859 |
858 } // namespace l10n_util | 860 } // namespace l10n_util |
OLD | NEW |