xtd 0.2.0
translator.h
Go to the documentation of this file.
1 #pragma once
6 #include "static.h"
7 #include "ustring.h"
8 #include <string>
9 #include <vector>
10 
12 namespace xtd {
25  class translator final static_ {
26  public:
28 
33  static xtd::ustring language();
38  static void language(const xtd::ustring& language);
39 
42  static std::vector<xtd::ustring> languages();
43 
48 
50 
57  static void add_value(const xtd::ustring& language, const xtd::ustring& key, const xtd::ustring& value);
58 
61  static void parse_locale(const xtd::ustring& locale_path);
62 
66  static void parse_file(const xtd::ustring& file, const xtd::ustring& language);
67 
71  static xtd::ustring translate(const xtd::ustring& value) noexcept;
76  static xtd::ustring translate(const xtd::ustring& language, const xtd::ustring& value) noexcept;
78 
80  static const char* translate(const char* value) noexcept;
81  static const char* translate(const xtd::ustring& language, const char* value) noexcept;
83 
84  private:
85  static void initialize();
86  static std::map<xtd::ustring, xtd::collections::specialized::string_map> language_values_;
87  static xtd::ustring language_;
88  };
89 }
Contains xtd::static_object class.
static void parse_file(const xtd::ustring &file, const xtd::ustring &language)
Parses a specified file that contains translations for a specified language.
#define static_
This keyword is use to represent a static object. A static object can&#39;t be instantiated (constructors...
Definition: static.h:37
static xtd::ustring translate(const xtd::ustring &value) noexcept
Translates a string into the lganguage specified by the xtd::translate::language property.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::collections::specialized::string_map typedef.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
static void add_value(const xtd::ustring &language, const xtd::ustring &key, const xtd::ustring &value)
Manually adds a translation for a specified key and language.
Contains xtd::ustring class.
static std::vector< xtd::ustring > languages()
Gets an array of languages supported by the application.
static xtd::ustring system_language()
Gets the current system language.
static void parse_locale(const xtd::ustring &locale_path)
Parses a specified path that contains translations.
static xtd::ustring language()
Gets the current application language.
Represents translator class. This class cannot be inherited.
Definition: translator.h:25