更新语言包;增加语言属性配置接口(语言包属性目前暂时屏蔽,直接返回空配置。如要启用,直接返回真实的配置内容即可)

This commit is contained in:
gb 2023-06-15 10:12:49 +08:00
parent becddfa8a6
commit 16ce3b39c9
2 changed files with 1470 additions and 1420 deletions

View File

@ -162,6 +162,7 @@ class lang_mgr
uint32_t os_cp_; uint32_t os_cp_;
uint32_t cur_cp_; uint32_t cur_cp_;
std::string cur_lang_; std::string cur_lang_;
std::string lang_opt_range_;
std::map<uint32_t, std::string> map_off_; std::map<uint32_t, std::string> map_off_;
static lang_mgr* inst_; static lang_mgr* inst_;
@ -491,13 +492,14 @@ class lang_mgr
#endif #endif
} }
lang_mgr() : os_cp_(lang_mgr::get_os_code_page()), cur_cp_(-1), cur_lang_(""), all_(nullptr), in_changing_(true), pak_now_(&map_off_) lang_mgr() : os_cp_(lang_mgr::get_os_code_page()), cur_cp_(-1), cur_lang_(""), all_(nullptr), in_changing_(true), pak_now_(&map_off_), lang_opt_range_("")
{ {
std::string path(get_module_path()); std::string path(get_module_path());
size_t pos = path.rfind(PATH_SEPERATOR[0]); size_t pos = path.rfind(PATH_SEPERATOR[0]);
char *str = nullptr; char *str = nullptr;
LANATTR *st = nullptr; LANATTR *st = nullptr;
int ind = 0; int ind = 0;
std::string prej("[");
if (pos++ == std::string::npos) if (pos++ == std::string::npos)
pos = 0; pos = 0;
@ -507,13 +509,20 @@ class lang_mgr
parse_pak(g_chinese, nullptr, nullptr, map_default_); parse_pak(g_chinese, nullptr, nullptr, map_default_);
enum_files(path.c_str(), &lang_mgr::found_language_pak, this, false); enum_files(path.c_str(), &lang_mgr::found_language_pak, this, false);
// code_pages_.push_back(cp_default_); // for all language ...
code_pages_.insert(code_pages_.begin(), cp_default_);
size_t len = sizeof(LANATTR*) * (code_pages_.size() + 1) + sizeof(LANATTR) * code_pages_.size(); size_t len = sizeof(LANATTR*) * (code_pages_.size() + 1) + sizeof(LANATTR) * code_pages_.size();
// "range": ["中文(简体)", "中文(繁体)", "英语"]
lang_opt_range_ = "{\"language\":{\"cat\":\"common\",\"group\":\"base\",\"title\":\"\\u8bed\\u8a00\",\"desc\":\"\\u8bbe\\u7f6e\\u8bed\\u8a00\\u5305\",\"ver\":1,\"pos\":0,\"fix-id\":34908,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":54,\"cur\":\"\\u4e2d\\u6587\\uFF08\\u7b80\\u4f53\\uFF09\",\"default\":\"\\u4e2d\\u6587\\uFF08\\u7b80\\u4f53\\uFF09\",\"range\":";
pos = len; pos = len;
for (const auto& v: code_pages_) for (const auto& v: code_pages_)
{ {
len += v.name.length() + 4; len += v.name.length() + 4;
lang_opt_range_ += prej + "\"" + transform_language(v.name.c_str(), true, nullptr) + "\"";
prej = ",";
} }
lang_opt_range_ += "]}}";
all_ = (LANATTR**)new char[len]; all_ = (LANATTR**)new char[len];
memset(all_, 0, len); memset(all_, 0, len);
@ -529,6 +538,8 @@ class lang_mgr
str += v.name.length() + 2; str += v.name.length() + 2;
st++; st++;
} }
// code_pages_.pop_back(); // delete default page
code_pages_.erase(code_pages_.begin());
if (map_off_.empty()) if (map_off_.empty())
{ {
@ -746,6 +757,10 @@ public:
{ {
notify_changed(); notify_changed();
} }
const char* supported_language_option_json(void)
{
return lang_opt_range_.c_str();
}
}; };
lang_mgr* lang_mgr::inst_ = nullptr; lang_mgr* lang_mgr::inst_ = nullptr;
@ -797,4 +812,31 @@ extern "C"
{ {
lang_mgr::instance()->notify_language_changed(); lang_mgr::instance()->notify_language_changed();
} }
//{
// "language": {
// "cat": "common",
// "group": "base",
// "title": "语言",
// "desc": "设置语言包",
// "ver": 1,
// "pos": 0,
// "fix-id": 34908,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 54,
// "cur": "中文(简体)",
// "default": "中文(简体)",
// "range": ["中文(简体)", "中文(繁体)", "英语"]
// }
//}
const char* language_option_descriptor(void)
{
return nullptr;
return lang_mgr::instance()->supported_language_option_json();
}
} }

2846
base_pak.h

File diff suppressed because it is too large Load Diff