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:
|
|
|
|
string language;
|
2011-06-08 09:18:06 +02:00
|
|
|
bool is_utf8_language;
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
Properties strings;
|
|
|
|
Properties scenarioStrings;
|
2012-05-02 22:46:47 +02:00
|
|
|
Properties techTreeStrings;
|
2012-05-03 16:43:28 +02:00
|
|
|
Properties techTreeStringsDefault;
|
2012-05-11 07:49:47 +02:00
|
|
|
Properties tilesetStrings;
|
|
|
|
Properties tilesetStringsDefault;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
2011-04-05 20:39:47 +02:00
|
|
|
std::map<string,Properties> otherLanguageStrings;
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
private:
|
2011-06-08 09:18:06 +02:00
|
|
|
Lang();
|
2011-11-19 04:33:01 +01:00
|
|
|
void loadStrings(string language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
|
|
|
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
|
|
|
|
2011-11-19 04:33:01 +01:00
|
|
|
void loadStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
|
|
|
void loadScenarioStrings(string scenarioDir, string scenarioName);
|
2012-05-02 22:46:47 +02:00
|
|
|
void loadTechTreeStrings(string techTree);
|
2012-05-11 07:49:47 +02:00
|
|
|
void loadTilesetStrings(string tileset);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-11-02 18:17:28 +01:00
|
|
|
string get(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
|
|
|
bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false);
|
2010-09-07 07:25:40 +02:00
|
|
|
string getScenarioString(const string &s);
|
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;
|
2011-06-08 09:18:06 +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
|