xtd 0.2.0
Loading...
Searching...
No Matches
translator.h
Go to the documentation of this file.
1
4#pragma once
6#include "static.h"
7#include "ustring.h"
8#include <string>
9#include <map>
10#include <set>
11#include <vector>
12
14namespace xtd {
27 class translator final static_ {
28 public:
30
40 static void language(const xtd::ustring& language);
41
45 static std::locale locale();
49 static void locale(const xtd::ustring& value);
53 static void locale(const std::locale& value);
54
57 static std::vector<xtd::ustring> languages();
58
63
65
72 static void add_value(const xtd::ustring& language, const xtd::ustring& key, const xtd::ustring& value);
73
76 static void parse_locale(const xtd::ustring& locale_path);
77
81 static void parse_file(const xtd::ustring& file, const xtd::ustring& language);
82
86 static xtd::ustring translate(const xtd::ustring& value) noexcept;
91 static xtd::ustring translate(const xtd::ustring& language, const xtd::ustring& value) noexcept;
93
95 static const char* translate(const char* value) noexcept;
96 static const char* translate(const xtd::ustring& language, const char* value) noexcept;
98
99 private:
100 static void initialize();
101 static xtd::ustring locale_to_language(xtd::ustring locale);
102 static std::map<xtd::ustring, xtd::collections::specialized::string_map> language_values_;
103 static xtd::ustring language_;
104 static std::set<ustring> translated_languages_;
105 };
106}
Represents translator class. This class cannot be inherited.
Definition translator.h:27
static xtd::ustring translate(const xtd::ustring &language, const xtd::ustring &value) noexcept
Translates a string into the specified lganguage.
static void language(const xtd::ustring &language)
Sets the current application language.
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 std::locale locale()
Gets the global locale.
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.
static void locale(const xtd::ustring &value)
Sets the global locale.
static xtd::ustring language()
Gets the current application language.
static void parse_file(const xtd::ustring &file, const xtd::ustring &language)
Parses a specified file that contains translations for a specified language.
static std::vector< xtd::ustring > languages()
Gets an array of languages supported by the application.
static xtd::ustring translate(const xtd::ustring &value) noexcept
Translates a string into the lganguage specified by the xtd::translate::language property.
static void locale(const std::locale &value)
Sets the global locale.
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::static_object class.
Contains xtd::collections::specialized::string_map typedef.
Contains xtd::ustring class.