bool LanguageManager::loadLanguage(const std::string & _file, const std::string & _group, bool _user) { if (!_group.empty()) { if (!helper::isFileExist(_file, _group)) { MYGUI_LOG(Error, "file '" << _file << "' not found in group'" << _group << "'"); return false; } Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingletonPtr()->openResource(_file, _group); // проверяем на сигнатуру utf8 uint32 sign = 0; stream->read((void*)&sign, 3); if (sign != 0x00BFBBEF) { MYGUI_LOG(Error, "file '" << _file << "' is not UTF8 format"); return false; } _loadLanguage(stream, _user); return true; } std::ifstream stream(_file.c_str()); if (false == stream.is_open()) { MYGUI_LOG(Error, "error open file '" << _file << "'"); return false; } // проверяем на сигнатуру utf8 uint32 sign = 0; stream.read((char*)&sign, 3); if (sign != 0x00BFBBEF) { MYGUI_LOG(Error, "file '" << _file << "' is not UTF8 format"); stream.close(); return false; } _loadLanguage(stream, _user); stream.close(); return true; }
bool LanguageManager::loadLanguage(const std::string& _file, bool _user) { DataStreamHolder data = DataManager::getInstance().getData(_file); if (data.getData() == nullptr) { MYGUI_LOG(Error, "file '" << _file << "' not found"); return false; } if (_file.find(".xml") != std::string::npos) _loadLanguageXML(data.getData(), _user); else _loadLanguage(data.getData(), _user); return true; }