ELTM
About
ELTM (Extension Language for Text Management) is a C++ extension language to manage more easily the texts and translations of your projects in Akel. Its use is not dissociable from C++ because it needs an instantiated ELTM context to use it. It is extremely simple and requires little time to learn it.
Syntax
// main.eltm
set my_id = my text
set my_long_id = (this is
a very
very long
text)
set something = get(my_long_id)
begin module my_module
set some_text = this is a text from my_module
set another_text = get(something)
end module
class CustomComponent : public Ak::Component
{
public:
void onAttach() override
{
Ak::ELTM eltm;
eltm.newContext("main.eltm");
std::cout << eltm.getText("my_long_id") << std::endl;
std::cout << Ak::ELTM::getText("my_module.some_text") << std::endl;
}
};
Member functions
Return type | Function | Specifiers |
---|---|---|
ELTM() | explicit |
|
~ELTM() | default |
|
bool |
load() | |
std::string |
getText() | static |
std::string |
getLocalText() | |
const char* |
getFile() | |
std::unordered_map<std::string, std::string>& |
getCurrentText() | |
std::unordered_map<std::string, std::unordered_map<std::string, std::string>& |
getCurrentModules() |
Constructor
Creates a new ELTM context that can be global or local.
If an ELTM context is global, you can get his texts from
the static method getText()
or from any other ELTM context.
If it is local, only this ELTM context can access its texts.
By default an ELTM context is global.
// Prototype
explicit ELTM(bool is_global = true);
// Usage
Ak::ELTM eltm;
// or
Ak::ELTM eltm(false);
Destructor
Deletes a new ELTM context.
// Prototype
~ELTM() = default;
load(std::string file)
Loads a new file to store its texts.
// Prototype
bool load(std::string file);
// Usage
eltm.load("eltm/file.eltm");
getText(std::string ID)
Returns the loaded text corresponding to the given ID.
// Prototype
static std::string getText(const std::string& ID);
// Usage
eltm.getText("my_ID");
// or if the context that loaded the text is global
Ak::ELTM::getText("my_ID");
getLocalText(std::string ID)
Returns the loaded text corresponding to the given ID.
// Prototype
bool load(std::string file);
// Usage
eltm.load("eltm/file.eltm"); // it is useful with global contexts
getFile()
Returns the file loaded.
// Prototype
const char* getFile();
// Usage
eltm.getFile();
getCurrentTexts()
Returns all the texts that have been loaded by this context.
// Prototype
std::unordered_map<std::string, std::string>& getCurrentTexts();
// Usage
eltm.getCurrentTexts();
getCurrentModule()
Returns all the modules that have been loaded by this context.
// Prototype
std::unordered_map<std::string, std::unordered_map<std::string>>& getCurrentModules();
// Usage
eltm.getCurrentModules();