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 "string.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::string& language);
41
45 static std::locale locale();
49 static void locale(const xtd::string& value);
53 static void locale(const std::locale& value);
54
57 static std::vector<xtd::string> languages();
58
63
65
72 static void add_value(const xtd::string& language, const xtd::string& key, const xtd::string& value);
73
76 static void parse_locale(const xtd::string& locale_path);
77
81 static void parse_file(const xtd::string& file, const xtd::string& language);
82
86 static xtd::string translate(const xtd::string& value) noexcept;
91 static xtd::string translate(const xtd::string& language, const xtd::string& value) noexcept;
93
95 static const char* translate(const char* value) noexcept;
96 static const char* translate(const xtd::string& language, const char* value) noexcept;
98
99 private:
100 static void initialize();
101 static xtd::string locale_to_language(xtd::string locale);
102 static std::map<xtd::string, xtd::collections::specialized::string_dictionary> language_values_;
103 static xtd::string language_;
104 static std::set<string> translated_languages_;
105 };
106}
Represents text as a sequence of character units.
Definition basic_string.h:79
Represents translator class. This class cannot be inherited.
Definition translator.h:27
static void add_value(const xtd::string &language, const xtd::string &key, const xtd::string &value)
Manually adds a translation for a specified key and language.
static xtd::string language()
Gets the current application language.
static void locale(const xtd::string &value)
Sets the global locale.
static xtd::string translate(const xtd::string &language, const xtd::string &value) noexcept
Translates a string into the specified lganguage.
static void language(const xtd::string &language)
Sets the current application language.
static xtd::string translate(const xtd::string &value) noexcept
Translates a string into the lganguage specified by the xtd::translate::language property.
static std::locale locale()
Gets the global locale.
static void parse_file(const xtd::string &file, const xtd::string &language)
Parses a specified file that contains translations for a specified language.
static void parse_locale(const xtd::string &locale_path)
Parses a specified path that contains translations.
static xtd::string system_language()
Gets the current system language.
static void locale(const std::locale &value)
Sets the global locale.
static std::vector< xtd::string > languages()
Gets an array of languages supported by the application.
#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::string alias.
Contains xtd::collections::specialized::string_dictionary typedef.