Planeshift
|
00001 /* 00002 * localization.h - Author: Ondrej Hurt 00003 * 00004 * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 00021 00022 #ifndef LOCALIZATION_HEADER 00023 #define LOCALIZATION_HEADER 00024 00025 #include <cstypes.h> 00026 #include <csutil/hash.h> 00027 #include <csutil/csstring.h> 00028 00029 struct iObjectRegistry; 00030 00035 struct psStringTableItem 00036 { 00037 csString original; 00038 csString translated; 00039 }; 00040 00041 typedef csHash<psStringTableItem*,csString> psStringTableHash; 00042 00045 class psLocalization 00046 { 00047 public: 00048 psLocalization(); 00049 ~psLocalization(); 00050 00051 void Initialize(iObjectRegistry* _object_reg); 00052 00053 // Sets name of the language used by this program 00054 void SetLanguage(const csString & lang); 00055 00056 /* Converts stardard path to a file to the VFS path to it. 00057 * It tries to search for the file in directory of the current language /this/lang/<language>/<shortPath> . 00058 * If not found, then the standard path is simply returned back with "/this/" prefix. 00059 * 00060 * Examples of shortPath: "charpick.xml" 00061 * "art/buttons/group.gif" 00062 */ 00063 csString FindLocalizedFile(const csString & shortPath); 00064 00066 const csString& Translate(const csString & orig); 00067 00069 bool FileExists(const csString & fileName); 00070 00071 protected: 00072 void ClearStringTable(); 00073 void WriteStringTable(); 00074 00075 csString language; 00076 csString filename; 00077 csString authors; 00078 bool dirty; 00079 psStringTableHash stringTbl; 00080 iObjectRegistry* object_reg; 00081 }; 00082 00085 #endif