Changed: #1307 Added extract bot names and UI dialog for plugin settings.
--HG-- branch : gsoc2011-translationovqthg/feature/gsoc2012-fabien
parent
9dab149983
commit
0371b04509
@ -0,0 +1,756 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/config_file.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/diff_tool.h"
|
||||
#include "nel/georges/u_form.h"
|
||||
#include "nel/georges/u_form_elm.h"
|
||||
#include "nel/georges/load_form.h"
|
||||
#include "nel/ligo/ligo_config.h"
|
||||
#include "nel/ligo/primitive.h"
|
||||
#include "nel/ligo/primitive_utils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLLIGO;
|
||||
using namespace STRING_MANAGER;
|
||||
|
||||
vector<string> Filters;
|
||||
|
||||
static CLigoConfig LigoConfig;
|
||||
static bool RemoveOlds = false;
|
||||
|
||||
struct TCreatureInfo
|
||||
{
|
||||
CSheetId SheetId;
|
||||
bool ForceSheetName;
|
||||
bool DisplayName;
|
||||
|
||||
|
||||
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId)
|
||||
{
|
||||
const NLGEORGES::UFormElm &item=form->getRootNode();
|
||||
|
||||
SheetId=sheetId;
|
||||
item.getValueByName(ForceSheetName, "3d data.ForceDisplayCreatureName");
|
||||
item.getValueByName(DisplayName, "3d data.DisplayName");
|
||||
}
|
||||
|
||||
void serial(NLMISC::IStream &f)
|
||||
{
|
||||
f.serial(SheetId);
|
||||
f.serial(ForceSheetName);
|
||||
f.serial(DisplayName);
|
||||
}
|
||||
|
||||
|
||||
static uint getVersion ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void removed()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
std::map<CSheetId, TCreatureInfo> Creatures;
|
||||
|
||||
TCreatureInfo *getCreature(const std::string &sheetName)
|
||||
{
|
||||
CSheetId id(sheetName+".creature");
|
||||
|
||||
if (Creatures.find(id) != Creatures.end())
|
||||
return &(Creatures.find(id)->second);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string cleanupName(const std::string &name)
|
||||
{
|
||||
string ret;
|
||||
|
||||
for (uint i=0; i<name.size(); ++i)
|
||||
{
|
||||
if (name[i] != ' ')
|
||||
ret += name[i];
|
||||
else
|
||||
ret += '_';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ucstring cleanupUcName(const ucstring &name)
|
||||
{
|
||||
ucstring ret;
|
||||
|
||||
for (uint i=0; i<name.size(); ++i)
|
||||
{
|
||||
if (name[i] != ' ')
|
||||
ret += name[i];
|
||||
else
|
||||
ret += '_';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Removes first and last '$'
|
||||
*/
|
||||
ucstring makeGroupName(const ucstring & translationName)
|
||||
{
|
||||
ucstring ret = translationName;
|
||||
if (ret.size() >= 2)
|
||||
{
|
||||
if ( *ret.begin() == ucchar('$'))
|
||||
{
|
||||
ret=ret.substr(1);
|
||||
}
|
||||
if ( *ret.rbegin() == ucchar('$'))
|
||||
{
|
||||
ret = ret.substr(0, ret.size()-1);
|
||||
}
|
||||
}
|
||||
ret = cleanupUcName(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct TEntryInfo
|
||||
{
|
||||
string SheetName;
|
||||
};
|
||||
|
||||
set<string> GenericNames;
|
||||
map<string, TEntryInfo> SimpleNames;
|
||||
set<string> Functions;
|
||||
|
||||
|
||||
string removeAndStoreFunction(const std::string &fullName)
|
||||
{
|
||||
string::size_type pos = fullName.find("$");
|
||||
if (pos == string::npos)
|
||||
return fullName;
|
||||
else
|
||||
{
|
||||
// extract and store the function name
|
||||
string ret;
|
||||
|
||||
ret = fullName.substr(0, pos);
|
||||
string::size_type pos2 = fullName.find("$", pos+1);
|
||||
|
||||
string fct = fullName.substr(pos+1, pos2-(pos+1));
|
||||
|
||||
ret += fullName.substr(pos2+1);
|
||||
|
||||
if (Functions.find(fct) == Functions.end())
|
||||
{
|
||||
nldebug("Adding function '%s'", fct.c_str());
|
||||
Functions.insert(fct);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void addGenericName(const std::string &name, const std::string &sheetName)
|
||||
{
|
||||
TCreatureInfo *c = getCreature(sheetName);
|
||||
if (!c || c->ForceSheetName || !c->DisplayName)
|
||||
return;
|
||||
|
||||
if (SimpleNames.find(name) != SimpleNames.end())
|
||||
{
|
||||
nldebug("Name '%s' is now a generic name", name.c_str());
|
||||
GenericNames.insert(name);
|
||||
SimpleNames.erase(name);
|
||||
|
||||
}
|
||||
else if (GenericNames.find(name) == GenericNames.end())
|
||||
{
|
||||
nldebug("Adding generic name '%s'", name.c_str());
|
||||
GenericNames.insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
void addSimpleName(const std::string &name, const std::string &sheetName)
|
||||
{
|
||||
TCreatureInfo *c = getCreature(sheetName);
|
||||
if (!c || c->ForceSheetName || !c->DisplayName)
|
||||
return;
|
||||
|
||||
if (SimpleNames.find(name) != SimpleNames.end())
|
||||
{
|
||||
addGenericName(name, sheetName);
|
||||
}
|
||||
else if (GenericNames.find(name) != GenericNames.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nldebug("Adding simple name '%s'", name.c_str());
|
||||
|
||||
TEntryInfo ei;
|
||||
ei.SheetName = sheetName;
|
||||
|
||||
SimpleNames.insert(make_pair(name, ei));
|
||||
}
|
||||
}
|
||||
|
||||
int extractBotNamesAll(map<string,list<string> > config_paths, string ligo_class_file, string trans_path, string work_path)
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// read the parameters
|
||||
/*for (int i=2; i<argc; ++i)
|
||||
{
|
||||
string s = argv[i];
|
||||
if (s == "-r")
|
||||
{
|
||||
// active remove mode
|
||||
RemoveOlds = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unknow option '%s'", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
} */
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// read the configuration file
|
||||
//CConfigFile cf;
|
||||
|
||||
//cf.load("bin/translation_tools.cfg");
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// read the vars
|
||||
//CConfigFile::CVar &paths = cf.getVar("Paths");
|
||||
//CConfigFile::CVar &filtersVar = cf.getVar("Filters");
|
||||
//CConfigFile::CVar &ligoClassFile= cf.getVar("LigoClassFile");
|
||||
//CConfigFile::CVar &georgesPaths= cf.getVar("GeorgesPaths");
|
||||
//CConfigFile::CVar &pathNoRecurse= cf.getVar("PathsNoRecurse");
|
||||
//CConfigFile::CVar &workBotNamesFile= cf.getVar("WorkBotNamesFile");
|
||||
//CConfigFile::CVar &transBotNamesFile= cf.getVar("TransBotNamesFile");
|
||||
//CConfigFile::CVar &workTitleFile= cf.getVar("WorkTitleFile");
|
||||
|
||||
for (std::list<string>::iterator it = config_paths["paths"].begin(); it != config_paths["paths"].end(); ++it)
|
||||
{
|
||||
CPath::addSearchPath(*it, true, false);
|
||||
}
|
||||
for (std::list<string>::iterator it = config_paths["pathsR"].begin(); it != config_paths["pathsR"].end(); ++it)
|
||||
{
|
||||
CPath::addSearchPath(*it, false, false);
|
||||
}
|
||||
|
||||
for (std::list<string>::iterator it = config_paths["filters"].begin(); it != config_paths["filters"].end(); ++it)
|
||||
{
|
||||
Filters.push_back(*it);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// init the sheets
|
||||
CSheetId::init(false);
|
||||
const string PACKED_SHEETS_NAME = "bin/translation_tools_creature.packed_sheets";
|
||||
loadForm("creature", PACKED_SHEETS_NAME, Creatures, false, false);
|
||||
|
||||
if (Creatures.empty())
|
||||
{
|
||||
for (std::list<string>::iterator it = config_paths["georges"].begin(); it != config_paths["georges"].end(); ++it)
|
||||
CPath::addSearchPath((*it).c_str(), true, false);
|
||||
|
||||
loadForm("creature", PACKED_SHEETS_NAME, Creatures, true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// init ligo config
|
||||
string ligoPath = CPath::lookup(ligo_class_file, true, true);
|
||||
LigoConfig.readPrimitiveClass(ligoPath.c_str(), false);
|
||||
NLLIGO::Register();
|
||||
|
||||
CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ok, ready for the real work,
|
||||
// first, read the primitives files and parse the primitives
|
||||
vector<string> files;
|
||||
CPath::getFileList("primitive", files);
|
||||
|
||||
for (uint i=0; i<files.size(); ++i)
|
||||
{
|
||||
string pathName = files[i];
|
||||
pathName = CPath::lookup(pathName);
|
||||
|
||||
// check filters
|
||||
uint j=0;
|
||||
for (j=0; j<Filters.size(); ++j)
|
||||
{
|
||||
if (pathName.find(Filters[j]) != string::npos)
|
||||
break;
|
||||
}
|
||||
if (j != Filters.size())
|
||||
// skip this file
|
||||
continue;
|
||||
|
||||
nlinfo("Loading file '%s'...", CFile::getFilename(pathName).c_str());
|
||||
|
||||
CPrimitives primDoc;
|
||||
CPrimitiveContext::instance().CurrentPrimitive = &primDoc;
|
||||
loadXmlPrimitiveFile(primDoc, pathName, LigoConfig);
|
||||
|
||||
// now parse the file
|
||||
|
||||
// look for group template
|
||||
{
|
||||
TPrimitiveClassPredicate pred("group_template_npc");
|
||||
TPrimitiveSet result;
|
||||
|
||||
CPrimitiveSet<TPrimitiveClassPredicate> ps;
|
||||
ps.buildSet(primDoc.RootNode, pred, result);
|
||||
|
||||
for (uint i=0; i<result.size(); ++i)
|
||||
{
|
||||
string name;
|
||||
string countStr;
|
||||
string sheetStr;
|
||||
result[i]->getPropertyByName("name", name);
|
||||
result[i]->getPropertyByName("count", countStr);
|
||||
result[i]->getPropertyByName("bot_sheet_look", sheetStr);
|
||||
|
||||
uint32 count;
|
||||
NLMISC::fromString(countStr, count);
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
if (sheetStr.empty())
|
||||
{
|
||||
nlwarning("In '%s', empty sheet !", buildPrimPath(result[i]).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
addGenericName(removeAndStoreFunction(name), sheetStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// look for bot template
|
||||
{
|
||||
TPrimitiveClassPredicate pred("bot_template_npc");
|
||||
TPrimitiveSet result;
|
||||
|
||||
CPrimitiveSet<TPrimitiveClassPredicate> ps;
|
||||
ps.buildSet(primDoc.RootNode, pred, result);
|
||||
|
||||
for (uint i=0; i<result.size(); ++i)
|
||||
{
|
||||
string name;
|
||||
string sheetStr;
|
||||
result[i]->getPropertyByName("name", name);
|
||||
result[i]->getPropertyByName("sheet_look", sheetStr);
|
||||
|
||||
if (sheetStr.empty())
|
||||
{
|
||||
// take the sheet in the parent
|
||||
result[i]->getParent()->getPropertyByName("bot_sheet_look", sheetStr);
|
||||
}
|
||||
|
||||
if (sheetStr.empty())
|
||||
{
|
||||
nlwarning("In '%s', empty sheet !", buildPrimPath(result[i]).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
addGenericName(removeAndStoreFunction(name), sheetStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
// look for npc_group
|
||||
{
|
||||
TPrimitiveClassPredicate pred("npc_group");
|
||||
TPrimitiveSet result;
|
||||
|
||||
CPrimitiveSet<TPrimitiveClassPredicate> ps;
|
||||
ps.buildSet(primDoc.RootNode, pred, result);
|
||||
|
||||
for (uint i=0; i<result.size(); ++i)
|
||||
{
|
||||
string name;
|
||||
string countStr;
|
||||
string sheetStr;
|
||||
result[i]->getPropertyByName("name", name);
|
||||
result[i]->getPropertyByName("count", countStr);
|
||||
result[i]->getPropertyByName("bot_sheet_client", sheetStr);
|
||||
|
||||
uint32 count;
|
||||
NLMISC::fromString(countStr, count);
|
||||
|
||||
if (count > 0 && sheetStr.empty())
|
||||
{
|
||||
nlwarning("In '%s', empty sheet !", buildPrimPath(result[i]).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count == 1)
|
||||
{
|
||||
addSimpleName(removeAndStoreFunction(name), sheetStr);
|
||||
}
|
||||
else if (count > 1)
|
||||
{
|
||||
addGenericName(removeAndStoreFunction(name), sheetStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// look for bot
|
||||
{
|
||||
TPrimitiveClassPredicate pred("npc_bot");
|
||||
TPrimitiveSet result;
|
||||
|
||||
CPrimitiveSet<TPrimitiveClassPredicate> ps;
|
||||
ps.buildSet(primDoc.RootNode, pred, result);
|
||||
|
||||
for (uint i=0; i<result.size(); ++i)
|
||||
{
|
||||
string name;
|
||||
string sheetStr;
|
||||
result[i]->getPropertyByName("name", name);
|
||||
result[i]->getPropertyByName("sheet_client", sheetStr);
|
||||
|
||||
if (sheetStr.empty())
|
||||
{
|
||||
// take the sheet in the parent
|
||||
result[i]->getParent()->getPropertyByName("bot_sheet_client", sheetStr);
|
||||
}
|
||||
|
||||
if (sheetStr.empty())
|
||||
{
|
||||
nlwarning("In '%s', empty sheet !", buildPrimPath(result[i]).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
TEntryInfo ei;
|
||||
addSimpleName(removeAndStoreFunction(name), sheetStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// step 2 : load the reference file
|
||||
|
||||
nlinfo("Looking for missing translation:");
|
||||
|
||||
TWorksheet botNames;
|
||||
loadExcelSheet(work_path, botNames, true);
|
||||
TWorksheet transBotNames;
|
||||
loadExcelSheet(trans_path, transBotNames, true);
|
||||
|
||||
TWorksheet fcts;
|
||||
loadExcelSheet(work_path, fcts, true);
|
||||
|
||||
|
||||
// add missing element
|
||||
|
||||
uint nbAddSimpleName = 0;
|
||||
uint nbAddFunction = 0;
|
||||
uint nbAddGenericName = 0;
|
||||
|
||||
uint botIdCol;
|
||||
nlverify(botNames.findId(botIdCol));
|
||||
uint transIdCol;
|
||||
nlverify(transBotNames.findId(transIdCol));
|
||||
uint fctsIdCol;
|
||||
nlverify(fcts.findId(fctsIdCol));
|
||||
|
||||
// special treatment to add the sheet_name col
|
||||
{
|
||||
uint sheetCol;
|
||||
if (!botNames.findCol(ucstring("sheet_name"), sheetCol))
|
||||
{
|
||||
botNames.insertColumn(botNames.ColCount);
|
||||
botNames.setData(0, botNames.ColCount-1, ucstring("sheet_name"));
|
||||
}
|
||||
|
||||
if (!transBotNames.findCol(ucstring("sheet_name"), sheetCol))
|
||||
{
|
||||
transBotNames.insertColumn(transBotNames.ColCount);
|
||||
transBotNames.setData(0, transBotNames.ColCount-1, ucstring("sheet_name"));
|
||||
}
|
||||
}
|
||||
// 1 - simple names
|
||||
{
|
||||
nlinfo(" Simple names...");
|
||||
|
||||
|
||||
map<string, TEntryInfo>::iterator first(SimpleNames.begin()), last(SimpleNames.end());
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
uint rowIdx;
|
||||
if (!botNames.findRow(botIdCol, first->first, rowIdx))
|
||||
{
|
||||
// we need to add the entry
|
||||
rowIdx = botNames.size();
|
||||
botNames.resize(botNames.size()+1);
|
||||
|
||||
botNames.setData(rowIdx, ucstring("bot name"), first->first);
|
||||
botNames.setData(rowIdx, ucstring("translated name"), first->first);
|
||||
botNames.setData(rowIdx, ucstring("sheet_name"), first->second.SheetName);
|
||||
|
||||
nbAddSimpleName++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set/update the sheet name info
|
||||
// try to restore the existing translation
|
||||
uint transRowIdx;
|
||||
if (transBotNames.findRow(transIdCol, first->first, transRowIdx))
|
||||
{
|
||||
ucstring wkBotName = botNames.getData(rowIdx, ucstring("bot name"));
|
||||
ucstring wkSheetName = botNames.getData(rowIdx, ucstring("sheet_name"));
|
||||
ucstring wkTranslationName = botNames.getData(rowIdx, ucstring("translated name"));
|
||||
ucstring ucWkHash;
|
||||
uint64 hash = CI18N::makeHash(wkBotName + wkTranslationName +wkSheetName);
|
||||
CI18N::hashToUCString(hash, ucWkHash);
|
||||
ucstring trUcHash = transBotNames[transRowIdx][0];
|
||||
bool isWkTranslationNameAGroupName = wkTranslationName.find(ucstring("$")) != ucstring::npos;
|
||||
bool hashIsValide = std::equal(ucWkHash.begin(), ucWkHash.end(), trUcHash.begin()+1);
|
||||
// Hash is equal get the translation
|
||||
if (hashIsValide && !isWkTranslationNameAGroupName)
|
||||
{
|
||||
wkTranslationName = transBotNames.getData(transRowIdx, ucstring("translated name"));
|
||||
wkSheetName = transBotNames.getData(transRowIdx, ucstring("sheet_name"));
|
||||
botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName);
|
||||
botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName);
|
||||
hash = CI18N::makeHash(wkBotName + wkTranslationName + wkSheetName);
|
||||
// update the hash code
|
||||
CI18N::hashToUCString(hash, transBotNames[transRowIdx][0]);
|
||||
}
|
||||
// bots_name.txt has been manually changed. We trust what the Level Designer has done. We don't destroy is work.
|
||||
// or it is a simple
|
||||
else
|
||||
{
|
||||
//use the "translated name" of the manually changed work/bot_name.txt
|
||||
botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName);
|
||||
botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2 - generic names
|
||||
|
||||
{
|
||||
nlinfo(" Generic names...");
|
||||
|
||||
set<string>::iterator first(GenericNames.begin()), last(GenericNames.end());
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
string gnName = "gn_" + cleanupName(*first);
|
||||
|
||||
ucstring fctsTitleId;
|
||||
ucstring fctsName;
|
||||
// add or modify the bot names
|
||||
uint rowIdx;
|
||||
if (!botNames.findRow(botIdCol, *first, rowIdx))
|
||||
{
|
||||
// we need to add the entry
|
||||
rowIdx = botNames.size();
|
||||
botNames.resize(botNames.size()+1);
|
||||
|
||||
botNames.setData(rowIdx, ucstring("bot name"), *first);
|
||||
botNames.setData(rowIdx, ucstring("translated name"), ucstring("$") + gnName + "$");
|
||||
botNames.setData(rowIdx, ucstring("sheet_name"), ucstring());
|
||||
fctsTitleId = gnName;
|
||||
fctsName = *first;
|
||||
|
||||
nbAddSimpleName++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// look in the translated table to remember the translated name to write it in the string file
|
||||
ucstring wkBotName = botNames.getData(rowIdx, ucstring("bot name"));
|
||||
ucstring wkTranslationName = botNames.getData(rowIdx, ucstring("translated name"));
|
||||
ucstring wkSheetName = botNames.getData(rowIdx, ucstring("sheet_name"));
|
||||
|
||||
|
||||
nlinfo("Bot name:%s\n",wkBotName.toString().c_str());
|
||||
bool isWkTranslationNameAGroupName = wkTranslationName.find(ucstring("$")) != ucstring::npos;
|
||||
|
||||
if ( isWkTranslationNameAGroupName ) //work name looks like "$gn_***$: do not modify
|
||||
{
|
||||
|
||||
//Do not change work/bot_name.txt
|
||||
// update work/world_title.txt
|
||||
|
||||
ucstring transName;
|
||||
fctsTitleId = makeGroupName(wkTranslationName);
|
||||
uint transRowIdx;
|
||||
if (transBotNames.findRow(transIdCol, *first, transRowIdx))
|
||||
{
|
||||
transName = transBotNames.getData(transRowIdx, ucstring("translated name"));
|
||||
|
||||
if (transName.find(ucstring("$")) != ucstring::npos)
|
||||
{
|
||||
transName = fctsTitleId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transName = fctsTitleId;
|
||||
}
|
||||
//Do not touch anything
|
||||
botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName);
|
||||
botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName);
|
||||
// fctsTitleId = makeGroupName(wkTranslationName);
|
||||
fctsName = transName;
|
||||
|
||||
}
|
||||
else // WkTranslationName != "$gn*$"
|
||||
{
|
||||
uint transRowIdx;
|
||||
ucstring transName;
|
||||
ucstring wkSheetName;
|
||||
// Get the translation as a simple name.
|
||||
if (transBotNames.findRow(transIdCol, *first, transRowIdx))
|
||||
{
|
||||
|
||||
transName = transBotNames.getData(transRowIdx, ucstring("translated name"));
|
||||
ucstring trSheetName = transBotNames.getData(transRowIdx, ucstring("sheet_name"));
|
||||
|
||||
//tr."translation name" is
|
||||
if (transName.find(ucstring("$")) != ucstring::npos)
|
||||
{
|
||||
//get Translation, update hash
|
||||
botNames[rowIdx][1] = transName;
|
||||
botNames[rowIdx][2] = trSheetName;
|
||||
fctsTitleId = makeGroupName(transName);
|
||||
fctsName = makeGroupName(transName);
|
||||
ucstring trNewUcHash;
|
||||
uint64 hash = CI18N::makeHash(wkBotName + transName +trSheetName);
|
||||
CI18N::hashToUCString(hash, trNewUcHash);
|
||||
transBotNames[transRowIdx][0] = ucstring("_") + trNewUcHash;
|
||||
}
|
||||
else //botNames."translated name" != $gn_$ && tansName."translated name" != $gn_$
|
||||
{
|
||||
|
||||
// get the translation back
|
||||
//update work/bot_name.txt
|
||||
wkTranslationName = ucstring("$")+gnName+"$";
|
||||
botNames[rowIdx][0] = wkBotName;
|
||||
botNames[rowIdx][1] = wkTranslationName;
|
||||
botNames[rowIdx][2] = wkSheetName;
|
||||
|
||||
//update translated/bot_name.txt
|
||||
|
||||
fctsName = transName; //transName
|
||||
fctsTitleId = gnName;
|
||||
ucstring trNewUcHash;
|
||||
uint64 hash = CI18N::makeHash(botNames[rowIdx][0] + botNames[rowIdx][1] +botNames[rowIdx][2]);
|
||||
CI18N::hashToUCString(hash, trNewUcHash);
|
||||
transBotNames[transRowIdx][0] = ucstring("_") + trNewUcHash;
|
||||
}
|
||||
|
||||
}
|
||||
else //There is no translation yet
|
||||
{
|
||||
fctsName = wkTranslationName;
|
||||
wkTranslationName = ucstring("$")+gnName+"$";
|
||||
botNames[rowIdx][0] = wkBotName;
|
||||
botNames[rowIdx][1] = wkTranslationName;
|
||||
botNames[rowIdx][2] = wkSheetName;
|
||||
fctsTitleId = gnName;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// look for a corresponding entry
|
||||
uint gnNameRow;
|
||||
|
||||
|
||||
if (!fcts.findRow(fctsIdCol, fctsTitleId, gnNameRow))
|
||||
{
|
||||
|
||||
// not found, add it
|
||||
gnNameRow = fcts.size();
|
||||
fcts.resize(fcts.size()+1);
|
||||
fcts.setData(gnNameRow, ucstring("title_id"), fctsTitleId);
|
||||
fcts.setData(gnNameRow, ucstring("name"), fctsName);
|
||||
nbAddGenericName++;
|
||||
|
||||
}
|
||||
else //Update
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 3 - functions
|
||||
{
|
||||
nlinfo(" Functions...");
|
||||
|
||||
set<string>::iterator first(Functions.begin()), last(Functions.end());
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
string fctName = *first;
|
||||
// look for a corresponding entry
|
||||
uint functionRow;
|
||||
if (!fcts.findRow(fctsIdCol, fctName, functionRow))
|
||||
{
|
||||
// not found, add it
|
||||
functionRow = fcts.size();
|
||||
fcts.resize(fcts.size()+1);
|
||||
|
||||
fcts.setData(functionRow, ucstring("title_id"), fctName);
|
||||
fcts.setData(functionRow, ucstring("name"), *first);
|
||||
|
||||
nbAddFunction++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// display resum\E9
|
||||
nlinfo("Adding %u new simple name", nbAddSimpleName);
|
||||
nlinfo("Adding %u new generic name", nbAddGenericName);
|
||||
nlinfo("Adding %u new function name", nbAddFunction);
|
||||
|
||||
// saving the modified files
|
||||
|
||||
ucstring s = prepareExcelSheet(botNames);
|
||||
CI18N::writeTextFile(work_path, s, false);
|
||||
s = prepareExcelSheet(transBotNames);
|
||||
CI18N::writeTextFile(trans_path, s, false);
|
||||
s = prepareExcelSheet(fcts);
|
||||
CI18N::writeTextFile(work_path, s, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,92 +1,393 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CTranslationManagerSettingsPage</class>
|
||||
<widget class="QWidget" name="CTranslationManagerSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>458</width>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>GroupBox</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="5">
|
||||
<widget class="QListView" name="listView"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="text">
|
||||
<string>RadioButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="text">
|
||||
<string>RadioButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>CheckBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../object_viewer_qt.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CTranslationManagerSettingsPage</class>
|
||||
<widget class="QWidget" name="CTranslationManagerSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>490</width>
|
||||
<height>495</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Core paths</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Paths</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>318</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="paths_add">
|
||||
<property name="text">
|
||||
<string>dwadwadwa</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_add_item.png</normaloff>:/icons/ic_nel_add_item.png</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="paths_del">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_delete_item.png</normaloff>:/icons/ic_nel_delete_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="paths_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Paths non recursives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>218</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pathsR_add">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_add_item.png</normaloff>:/icons/ic_nel_add_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pathsR_del">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_delete_item.png</normaloff>:/icons/ic_nel_delete_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="pathsR_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Georges Paths</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>258</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="georges_add">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_add_item.png</normaloff>:/icons/ic_nel_add_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="georges_del">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_delete_item.png</normaloff>:/icons/ic_nel_delete_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="georges_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Translation files paths</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>230</y>
|
||||
<width>450</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Ligo class file - This is the name of the world_editor_classes.xml file.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="ligo_edit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Work directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="work_edit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="work_add">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Translation directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="translation_edit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="translation_add">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>10</y>
|
||||
<width>211</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Filters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="filter_edit"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="filter_add">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_add_item.png</normaloff>:/icons/ic_nel_add_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="filter_del">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_delete_item.png</normaloff>:/icons/ic_nel_delete_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QListWidget" name="filter_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>10</y>
|
||||
<width>221</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Languages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lang_edit"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="lang_add">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_add_item.png</normaloff>:/icons/ic_nel_add_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="lang_del">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../object_viewer/object_viewer.qrc">
|
||||
<normaloff>:/icons/ic_nel_delete_item.png</normaloff>:/icons/ic_nel_delete_item.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QListWidget" name="lang_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../object_viewer_qt.qrc"/>
|
||||
<include location="../object_viewer/object_viewer.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue