API Documentation
Loading...
Searching...
No Matches
Translator.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: Translator
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <NDEVR/INIFactory.h>
36#include <NDEVR/File.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/INIInterface.h>
39namespace NDEVR
40{
42 {
43 public:
44 Translator();
45 Translator(const String& translation_id);
46 Translator(const File& settings_file);
47 Translator(const Translator& translator);
48 virtual String convertNumber(const String& number_string, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits) const;
49 virtual String convertText(const String& text_string) const;
50 virtual String convertText(const String& text_string, const String& default_text) const;
51 void copyFrom(const Translator& trans, bool use_existing_ini_file);
52 void copyTranslationsFrom(const Translator& trans);
53 File translatorFile(bool user_file) const;
54 void getINI(INIFactory& factory) override;
55 INIFactory& translationINI() const;
56 static Dictionary<String, Translator> GetAvailableTranslations(File folder = File());
57 const String& id() const { return m_translation_id; }
58 const String& name() const { return m_language_name; }
59 void setID(const String& id);
60 bool isLeftToRight() const;
61 void setName(const String& name);
62 Translator& operator=(const Translator& translation);
63 String commonCharacters() const;
64 void saveTranslation(File location = File());
65 File activeTranslatorFile() const;
66 Dictionary<String, String> translatedStrings() const;
67 public:
68 static Translator* MainTranslator();
69 static void SetMainTranslator(Translator* translator);
70 static String DefaultLabel(const String& text_string);
71 protected:
72 void ensureLanguageLoaded() const;
73 void init();
80 char m_number_sep;//typically ,
81 char m_decimal_sep;//typically .
82 bool m_left_to_right;//typically true
83 public:
85 };
86 //Translate string
87 #define _t(english_string) (TranslatedString(Translator::DefaultLabel(english_string), english_string))
88 //Translate number
89 #define _tn(number_string, add_comma, min_decimals, max_decimals, min_digits) (Translator::MainTranslator()->convertNumber(number_string, add_comma, min_decimals, max_decimals, min_digits))
90 //Translate string by description
91 #define _td(def, english_string) (TranslatedString(Translator::DefaultLabel(def), english_string))
92}
93
#define NDEVR_BASE_API
Definition DLLInfo.h:78
Definition Dictionary.h:48
Definition File.h:47
Definition INIReader.h:57
Definition INIInterface.h:40
Definition Toggle.h:41
Definition String.h:40
Definition Translator.h:42
bool m_has_loaded_language
Definition Translator.h:79
String m_translation_id
Definition Translator.h:78
File m_translation_file
Definition Translator.h:75
INIFactory m_language_ini
Definition Translator.h:74
const String & id() const
Definition Translator.h:57
char m_decimal_sep
Definition Translator.h:81
bool m_left_to_right
Definition Translator.h:82
String m_language_name
Definition Translator.h:76
String m_common_characters
Definition Translator.h:77
char m_number_sep
Definition Translator.h:80
const String & name() const
Definition Translator.h:58
static Resource< Translator * > main_translator
Definition Translator.h:84
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120