问题描述
问题在于,每次启动进程时,它都会加载一个名为 MOfiles\de_DE\LC_MESSAGES\msg.mo (.mo extension) 的 13 MB 翻译文件,大约需要 1 秒完成。每个新流程都会遭受同样的延迟,从而降低用户的整体体验。
问题:是否可以在共享内存中创建单个翻译对象,以便任何新进程都可以引用该现有对象并避免延迟?
经过一些简短的研究,我发现了一个 Boost C++ example,它在共享内存中创建了一个向量。
它是否也适用于 boost 语言环境对象?
单进程翻译文件当前加载如下
void STDCALL SetGlobalLocale(const char* domain,const char* locale,const char* path,const char* charset)
{
std::string encoding(charset);
encoding.insert(0,".");
std::string language = locale ? (locale + encoding) : "";
boost::locale::generator gen;
gen.add_messages_path(path);
gen.add_messages_domain(domain);
// Sets a single global locale for the entire process.
std::locale loc = gen(language); // SLOW!!! Takes 1 second to load. ಠ_ಠ
std::locale::global(loc);
gen.clear_paths();
gen.clear_domains();
}
并调用使用
SetGlobalLocale("msg","de_DE","../../../../MOfiles","CP1252");
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)