LeviLamina
Loading...
Searching...
No Matches
Localization.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7
8// auto generated forward declare list
9// clang-format off
12struct OptionalString;
13// clang-format on
14
15class Localization {
16public:
17 // Localization inner types define
18 using Map = ::std::map<::std::string, ::std::string>;
19
20 using StoreLocMap = ::std::unordered_multimap<::std::string, ::std::pair<::std::string, ::std::string>>;
21
22public:
23 // member variables
24 // NOLINTBEGIN
25 ::ll::TypedStorage<1, 1, bool const> mCommaSeperator;
26 ::ll::TypedStorage<8, 32, ::std::string const> mDigitGroupSeparator;
27 ::ll::TypedStorage<8, 32, ::std::string const> mCode;
28 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::string>> mStrings;
29 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::string>> mCaseSensitiveCache;
30 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::shared_mutex>> mCaseSensitiveCacheMutex;
31 ::ll::TypedStorage<1, 1, bool> mMayContainIdentifier;
32 // NOLINTEND
33
34public:
35 // prevent constructor by default
36 Localization& operator=(Localization const&);
37 Localization();
38
39public:
40 // member functions
41 // NOLINTBEGIN
42 MCAPI explicit Localization(::std::string const& code);
43
44 MCAPI Localization(::Localization&& rhs);
45
46 MCAPI Localization(::Localization const& rhs);
47
48 MCAPI Localization(::std::string const& code, ::Localization const* fallbackLocale);
49
50 MCAPI ::OptionalString _get(::std::string const& id, ::std::vector<::std::string> const& params) const;
51
52 MCAPI ::OptionalString _getSimple(::std::string const& id) const;
53
54 MCAPI ::OptionalString _parseFormattedString(::std::string const& id) const;
55
56 MCAPI void
57 _replaceUTCDateTimeIdentifier(::std::string& strToParse, ::std::optional<::std::locale> const& locale) const;
58
59 MCAPI void addKeys(::Localization&& from);
60
61 MCAPI void appendTranslations(
62 ::std::unordered_multimap<::std::string, ::std::pair<::std::string, ::std::string>> const& locStrings
63 );
64
65 MCAPI void appendTranslations(::Localization const& other);
66
67 MCAPI void appendTranslations(
68 ::std::string const& fileContent,
69 ::std::vector<::std::string> const& blockedKeys,
70 ::std::vector<::std::string> const& allowedKeys,
71 ::std::string const& keyPrefix
72 );
73
74 MCAPI bool get(::std::string const& id, ::std::string& out, ::std::vector<::std::string> const& params) const;
75
76#ifdef LL_PLAT_C
77 MCFOLD bool getCommaSeperator() const;
78
79 MCFOLD ::std::string const getDigitGroupSeparator() const;
80#endif
81
82 MCFOLD ::std::string getFullLanguageCode() const;
83
84#ifdef LL_PLAT_C
85 MCAPI ::std::string getIETFLanguageCode() const;
86
87 MCAPI ::std::string getLanguageCode() const;
88
89 MCAPI ::std::string getRegionCode() const;
90
91 MCAPI bool getStringIdExists(::std::string const& key) const;
92
93 MCFOLD bool isLocReady() const;
94#endif
95
96 MCAPI void loadFromPack(
97 ::std::string const& keyPrefix,
98 ::PackAccessStrategy const& accessStrategy,
99 ::std::vector<::std::string> const& allowedKeys
100 );
101
102 MCAPI void loadFromResourcePackManager(
103 ::ResourcePackManager& resourcePackManager,
104 ::std::vector<::std::string> const& blockedKeys
105 );
106
107 MCAPI void replaceIdentifiers();
108
109 MCAPI ~Localization();
110 // NOLINTEND
111
112public:
113 // static functions
114 // NOLINTBEGIN
115 MCAPI static ::std::string _getDigitGroupSeparator(::std::string const& langCode);
116
117 MCAPI static bool _isCommaSeperatedLanguage(::std::string const& langCode);
118
119 MCAPI static ::Core::PathBuffer<::std::string> getLangFilePath(::std::string const& langCode);
120
121 MCAPI static ::std::string getLanguageCode(::std::string const& fullCode);
122
123#ifdef LL_PLAT_C
124 MCAPI static ::std::string getRegionCode(::std::string const& fullCode);
125
126 MCAPI static bool isFormattedString(::std::string const& id);
127#endif
128
129 MCAPI static bool isValidLanguageCode(::std::string const& code);
130
131 MCAPI static void replaceTokens(::std::string& string, ::std::vector<::std::string> const& params);
132 // NOLINTEND
133
134public:
135 // constructor thunks
136 // NOLINTBEGIN
137 MCAPI void* $ctor(::std::string const& code);
138
139 MCAPI void* $ctor(::Localization&& rhs);
140
141 MCAPI void* $ctor(::Localization const& rhs);
142
143 MCAPI void* $ctor(::std::string const& code, ::Localization const* fallbackLocale);
144 // NOLINTEND
145
146public:
147 // destructor thunk
148 // NOLINTBEGIN
149 MCAPI void $dtor();
150 // NOLINTEND
151};
Definition PackAccessStrategy.h:26
Definition ResourcePackManager.h:35
Definition OptionalString.h:5
Definition code.h:5