localized_values_builder.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_LOGIN_LOCALIZED_VALUES_BUILDER_H_
  5. #define COMPONENTS_LOGIN_LOCALIZED_VALUES_BUILDER_H_
  6. #include <string>
  7. #include "base/values.h"
  8. #include "components/login/login_export.h"
  9. namespace login {
  10. // Class that collects Localized Values for translation.
  11. class LOGIN_EXPORT LocalizedValuesBuilder {
  12. public:
  13. explicit LocalizedValuesBuilder(base::Value::Dict* dict);
  14. // Method to declare localized value. |key| is the i18n key used in html.
  15. // |message| is text of the message.
  16. void Add(const std::string& key, const std::string& message);
  17. // Method to declare localized value. |key| is the i18n key used in html.
  18. // |message| is text of the message.
  19. void Add(const std::string& key, const std::u16string& message);
  20. // Method to declare localized value. |key| is the i18n key used in html.
  21. // |message_id| is a resource id of message.
  22. void Add(const std::string& key, int message_id);
  23. // Method to declare localized value. |key| is the i18n key used in html.
  24. // |message_id| is a resource id of message. Message is expected to have
  25. // one format parameter subsituted by |a|.
  26. void AddF(const std::string& key, int message_id, const std::u16string& a);
  27. // Method to declare localized value. |key| is the i18n key used in html.
  28. // |message_id| is a resource id of message. Message is expected to have
  29. // two format parameters subsituted by |a| and |b| respectively.
  30. void AddF(const std::string& key,
  31. int message_id,
  32. const std::u16string& a,
  33. const std::u16string& b);
  34. // Method to declare localized value. |key| is the i18n key used in html.
  35. // |message_id| is a resource id of message. Message is expected to have
  36. // two format parameters subsituted by |a|, |b| and |c| respectively.
  37. void AddF(const std::string& key,
  38. int message_id,
  39. const std::u16string& a,
  40. const std::u16string& b,
  41. const std::u16string& c);
  42. // Method to declare localized value. |key| is the i18n key used in html.
  43. // |message_id| is a resource id of message. Message is expected to have
  44. // one format parameter subsituted by resource identified by |message_id_a|.
  45. void AddF(const std::string& key, int message_id, int message_id_a);
  46. // Method to declare localized value. |key| is the i18n key used in html.
  47. // |message_id| is a resource id of message. Message is expected to have
  48. // two format parameters subsituted by resource identified by |message_id_a|
  49. // and |message_id_b| respectively.
  50. void AddF(const std::string& key,
  51. int message_id,
  52. int message_id_a,
  53. int message_id_b);
  54. // Method to declare localized value. |key| is the i18n key used in html.
  55. // |message_id| is a resource id of message. Message is expected to have
  56. // three format parameters subsituted by resource identified by
  57. // |message_id_a|, |message_id_b| and |message_id_c| respectively.
  58. void AddF(const std::string& key,
  59. int message_id,
  60. int message_id_a,
  61. int message_id_b,
  62. int message_id_c);
  63. private:
  64. std::string prefix_;
  65. // Not owned.
  66. base::Value::Dict* dict_;
  67. };
  68. } // namespace login
  69. #endif // COMPONENTS_LOGIN_LOCALIZED_VALUES_BUILDER_H_