mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
content translation + gui.str function
This commit is contained in:
parent
7359b0e10a
commit
0838208fb6
5 changed files with 38 additions and 45 deletions
|
|
@ -243,6 +243,8 @@ void Engine::loadContent() {
|
|||
|
||||
Shader::preprocessor->setPaths(resPaths.get());
|
||||
|
||||
langs::setup(resdir, langs::current->getId(), contentPacks);
|
||||
|
||||
std::unique_ptr<Assets> new_assets(new Assets());
|
||||
std::cout << "-- loading assets" << std::endl;
|
||||
AssetsLoader loader(new_assets.get(), resPaths.get());
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void langs::load(const fs::path& resdir,
|
|||
if (fs::is_regular_file(file)) {
|
||||
std::string text = files::read_string(file);
|
||||
Reader reader(file.string(), text);
|
||||
reader.read(lang, pack.id+":");
|
||||
reader.read(lang, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "../../../graphics/ui/elements/UINode.h"
|
||||
#include "../../../graphics/ui/elements/controls.h"
|
||||
#include "../../../frontend/UiDocument.h"
|
||||
#include "../../../frontend/locale/langs.h"
|
||||
#include "../../../util/stringutil.h"
|
||||
|
||||
static gui::UINode* getDocumentNode(lua_State* L, const std::string& name, const std::string& nodeName) {
|
||||
|
|
@ -320,10 +321,22 @@ static int l_gui_get_env(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int l_gui_str(lua_State* L) {
|
||||
auto text = util::str2wstr_utf8(lua_tostring(L, 1));
|
||||
if (!lua_isnoneornil(L, 2)) {
|
||||
auto context = util::str2wstr_utf8(lua_tostring(L, 2));
|
||||
lua_pushstring(L, util::wstr2str_utf8(langs::get(text, context)).c_str());
|
||||
} else {
|
||||
lua_pushstring(L, util::wstr2str_utf8(langs::get(text)).c_str());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg guilib [] = {
|
||||
{"get_viewport", lua_wrap_errors<l_gui_getviewport>},
|
||||
{"getattr", lua_wrap_errors<l_gui_getattr>},
|
||||
{"setattr", lua_wrap_errors<l_gui_setattr>},
|
||||
{"get_env", lua_wrap_errors<l_gui_get_env>},
|
||||
{"str", lua_wrap_errors<l_gui_str>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue