2010-09-07 07:25:40 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2010-09-07 07:25:40 +02:00
|
|
|
//
|
|
|
|
// You can redistribute this code 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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_LANG_H_
|
|
|
|
#define _GLEST_GAME_LANG_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "properties.h"
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
using Shared::Util::Properties;
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class Lang
|
|
|
|
//
|
|
|
|
// String table
|
|
|
|
// =====================================================
|
|
|
|
|
2011-04-05 20:39:47 +02:00
|
|
|
class Lang {
|
2010-09-07 07:25:40 +02:00
|
|
|
private:
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2013-10-29 18:28:29 +01:00
|
|
|
bool is_utf8_language;
|
|
|
|
string language;
|
|
|
|
std::map<string,Properties> gameStringsAllLanguages;
|
2013-10-29 07:13:38 +01:00
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
Properties scenarioStrings;
|
2013-10-29 07:13:38 +01:00
|
|
|
|
2012-05-11 07:49:47 +02:00
|
|
|
Properties tilesetStrings;
|
|
|
|
Properties tilesetStringsDefault;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
2013-10-29 18:28:29 +01:00
|
|
|
std::map<string, std::map<string, Properties> > techTreeStringsAllLanguages;
|
2013-06-13 03:37:15 +02:00
|
|
|
string techNameLoaded;
|
|
|
|
bool allowNativeLanguageTechtree;
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
private:
|
2011-06-08 09:18:06 +02:00
|
|
|
Lang();
|
2013-10-29 07:13:38 +01:00
|
|
|
void loadGameStringProperties(string language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
2011-11-19 04:33:01 +01:00
|
|
|
bool fileMatchesISO630Code(string uselanguage, string testLanguageFile);
|
2011-12-01 00:35:54 +01:00
|
|
|
string getNativeLanguageName(string uselanguage, string testLanguageFile);
|
2010-09-07 07:25:40 +02:00
|
|
|
|
2011-12-03 04:35:36 +01:00
|
|
|
string parseResult(const string &key, const string &value);
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
public:
|
|
|
|
static Lang &getInstance();
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2013-10-29 21:24:23 +01:00
|
|
|
string getTechNameLoaded() const { return techNameLoaded; }
|
2013-06-13 03:37:15 +02:00
|
|
|
bool getAllowNativeLanguageTechtree() const { return allowNativeLanguageTechtree; }
|
|
|
|
void setAllowNativeLanguageTechtree(bool value) { allowNativeLanguageTechtree = value; }
|
|
|
|
|
2013-10-29 07:13:38 +01:00
|
|
|
void loadGameStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
2013-05-21 22:28:42 +02:00
|
|
|
void loadScenarioStrings(string scenarioDir, string scenarioName, bool isTutorial);
|
2013-10-31 21:12:49 +01:00
|
|
|
bool loadTechTreeStrings(string techTree, bool forceLoad=false);
|
2012-05-11 07:49:47 +02:00
|
|
|
void loadTilesetStrings(string tileset);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2013-10-29 07:13:38 +01:00
|
|
|
string getString(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
2011-11-02 18:17:28 +01:00
|
|
|
bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false);
|
2013-10-29 07:13:38 +01:00
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
string getScenarioString(const string &s);
|
2013-02-09 18:18:34 +01:00
|
|
|
bool hasScenarioString(const string &s);
|
2013-10-29 07:13:38 +01:00
|
|
|
|
2012-05-02 22:46:47 +02:00
|
|
|
string getTechTreeString(const string &s, const char *defaultValue=NULL);
|
2012-05-11 07:49:47 +02:00
|
|
|
string getTilesetString(const string &s, const char *defaultValue=NULL);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-04-05 20:39:47 +02:00
|
|
|
string getLanguage() const { return language; }
|
|
|
|
bool isLanguageLocal(string compareLanguage) const;
|
2017-10-10 08:09:52 +02:00
|
|
|
//bool isUTF8Language() const;
|
2011-12-05 01:02:32 +01:00
|
|
|
string getDefaultLanguage() const;
|
|
|
|
|
2011-12-01 01:20:14 +01:00
|
|
|
map<string,string> getDiscoveredLanguageList(bool searchKeyIsLangName=false);
|
2011-12-01 00:35:54 +01:00
|
|
|
pair<string,string> getNavtiveNameFromLanguageName(string langName);
|
2012-10-22 07:08:52 +02:00
|
|
|
|
|
|
|
string getLanguageFile(string uselanguage);
|
2010-09-07 07:25:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|