MultiLanguage.h
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:4k
源码类别:
P2P编程
开发平台:
Visual C++
- /*
- * Openmysee
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
- #pragma once
- #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
- // Windows Header Files:
- #include <windows.h>
- #include <tchar.h>
- #include <map>
- #include <fstream>
- #include <string>
- using namespace std;
- #ifdef _UNICODE
- #define tstring wstring
- #define tifstream wifstream
- #else
- #define tstring string
- #define tifstream ifstream
- #endif
- // Type definitions
- typedef struct LANGINFO_DEF {
- int Count;
- LANGID LangID;
- } LANGINFO;
- typedef LANGINFO *PLANGINFO;
- class StringMapLoader
- {
- public:
- StringMapLoader(void);
- virtual ~StringMapLoader(void);
- static bool SwitchLanguage(
- const LANGID langID // in, 语言ID
- );
- static bool GetCurLanguage(
- LANGID& langID // out, 当前语言的ID
- );
- /*
- static UINT GetAvailableLanguageCount();
- static bool GetAvailableLanguage()
- */
- static UINT GetStrByStr(
- const LPCTSTR keyStr, // in, 索引字符串
- LPTSTR buf, // out, 存储字符串的缓冲区
- const UINT bufSize // in, 缓冲区的大小
- );
- private:
- // 处理Windows NT4上Hongkong SAR version的问题
- LANGID GetNTDLLNativeLangID();
- BOOL IsHongKongVersion();
- // 获取本机使用的语言编号,如果找不到,则选择默认语言
- LANGID DetectLanguage();
- //根据文件名读取转译文件
- bool LoadLanguageFile(
- const string &filename // 目标文件,相对路径
- );
- private:
- enum {
- DEFAULT_LANG_ID = 0x0409, // 默认语言(英语)
- HONGKONG_LANG_ID = 0x0c04, // 香港默认语言
- TAIWAN_LANG_ID = 0x0404, // 台湾默认语言
- MAINLAND_LANG_ID = 0x0804, // 内地默认语言
- MAX_KEY_BUFFER = 80, // 字符语言ID的长度限制
- };
- map <LANGID, string> m_mapLangId2Str; // LanguageID与描述字符串的对应,比如0x0804对应"zh_CN", 0x0404对应"zh_TW"
- map <tstring, tstring> m_mapKeyStr2ValStr; // Key字符串 与 当前语言字符串的对应
- LANGID m_idCurLang; // 获取当前语言ID
- };
- #ifdef __cplusplus // If used by C++ code,
- extern "C" { // we need to export the C interface
- #endif
- // 改变当前语言
- __declspec(dllexport) bool SwitchLanguage(
- const LANGID langID // in, 语言的ID
- )
- {
- return StringMapLoader::SwitchLanguage(langID);
- }
- // 获取当前语言ID
- __declspec(dllexport) bool GetCurLanguage(
- LANGID& langID // out, 当前语言的ID
- )
- {
- return StringMapLoader::GetCurLanguage(langID);
- }
- /*
- // 获取可用的语言数目
- __declspec(dllexport) UINT GetAvailableLanguageCount()
- {
- return StringMapLoader::GetAvailableLanguageCount();
- }
- // 获取可用的语言列表
- __declspec(dllexport) bool GetAvailableLanguage(
- const LANGID* pList, // out, 存储列表的缓冲区
- const UINT maxSize // in, 列表的大小限制
- )
- {
- return StringMapLoader::GetAvailableLanguage();
- }
- */
- // 根据字符串获取对应的当前语言字符串,返回语言字符串的长度
- __declspec(dllexport) UINT GetStrByStr(
- LPCTSTR keyStr, // in, 索引字符串
- LPTSTR buf, // out, 存储字符串的缓冲区
- const UINT bufSize // in, 缓冲区的大小
- )
- {
- return StringMapLoader::GetStrByStr(keyStr, buf, bufSize);
- }
- #ifdef __cplusplus // If used by C++ code,
- }
- #endif