Changed: #1307 Added extraction words options for: item, creature, sbrick, sphrase
--HG-- branch : gsoc2011-translationovqthg/feature/gsoc2012-fabien
parent
e55bbed5b4
commit
a4f222c651
@ -0,0 +1,111 @@
|
||||
// Translation Manager Plugin - OVQT Plugin <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Emanuel Costea <cemycc@gmail.com>
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#ifndef EXTRACT_BOT_NAMES_H
|
||||
#define EXTRACT_BOT_NAMES_H
|
||||
|
||||
#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;
|
||||
|
||||
namespace Plugin
|
||||
{
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct TEntryInfo
|
||||
{
|
||||
string SheetName;
|
||||
};
|
||||
|
||||
struct ExtractBotNames
|
||||
{
|
||||
private:
|
||||
vector<string> Filters;
|
||||
std::map<CSheetId, TCreatureInfo> Creatures;
|
||||
set<string> GenericNames;
|
||||
map<string, TEntryInfo> SimpleNames;
|
||||
set<string> Functions;
|
||||
private:
|
||||
TCreatureInfo *getCreature(const std::string &sheetName);
|
||||
ucstring makeGroupName(const ucstring & translationName);
|
||||
string removeAndStoreFunction(const std::string &fullName);
|
||||
void addGenericName(const std::string &name, const std::string &sheetName);
|
||||
void addSimpleName(const std::string &name, const std::string &sheetName);
|
||||
public:
|
||||
void extractBotNamesFromPrimitives(CLigoConfig ligoConfig);
|
||||
void setRequiredSettings(list<string> filters, string level_design_path);
|
||||
set<string> getGenericNames();
|
||||
map<string, TEntryInfo> getSimpleNames();
|
||||
string cleanupName(const std::string &name);
|
||||
ucstring cleanupUcName(const ucstring &name);
|
||||
void cleanSimpleNames();
|
||||
void cleanGenericNames();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* EXTRACT_BOT_NAMES_H */
|
||||
|
@ -0,0 +1,154 @@
|
||||
// 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 "extract_new_sheet_names.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLLIGO;
|
||||
using namespace STRING_MANAGER;
|
||||
|
||||
namespace Plugin {
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/*
|
||||
* Specialisation of IWordListBuilder to list sheets in a directory
|
||||
*/
|
||||
|
||||
|
||||
bool CSheetWordListBuilder::buildWordList(std::vector<string> &allWords, string workSheetFileName)
|
||||
{
|
||||
SheetExt= toLower(SheetExt);
|
||||
nlinfo("aaaa");
|
||||
// verify the directory is correct
|
||||
if(!CFile::isDirectory(SheetPath))
|
||||
{
|
||||
nlwarning("Error: Directory '%s' not found. '%s' Aborted", SheetPath.c_str(), workSheetFileName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// list all files.
|
||||
std::vector<string> allFiles;
|
||||
allFiles.reserve(100000);
|
||||
CPath::getPathContent(SheetPath, true, false, true, allFiles, NULL);
|
||||
|
||||
// Keep only the extension we want, and remove "_" (parent)
|
||||
allWords.clear();
|
||||
allWords.reserve(allFiles.size());
|
||||
for(uint i=0;i<allFiles.size();i++)
|
||||
{
|
||||
string fileNameWithoutExt= CFile::getFilenameWithoutExtension(allFiles[i]);
|
||||
string extension= toLower(CFile::getExtension(allFiles[i]));
|
||||
// bad extension?
|
||||
if(extension!=SheetExt)
|
||||
continue;
|
||||
// parent?
|
||||
if(fileNameWithoutExt.empty()||fileNameWithoutExt[0]=='_')
|
||||
continue;
|
||||
// ok, add
|
||||
allWords.push_back(toLower(fileNameWithoutExt));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/*
|
||||
* Specialisation of IWordListBuilder to list new region/place name from .primitive
|
||||
*/
|
||||
bool CRegionPrimWordListBuilder::buildWordList(std::vector<string> &allWords, string workSheetFileName)
|
||||
{
|
||||
// verify the directory is correct
|
||||
if(!CFile::isDirectory(PrimPath))
|
||||
{
|
||||
nlwarning("Error: Directory '%s' not found. '%s' Aborted", PrimPath.c_str(), workSheetFileName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// list all files.
|
||||
std::vector<string> allFiles;
|
||||
allFiles.reserve(100000);
|
||||
CPath::getPathContent(PrimPath, true, false, true, allFiles, NULL);
|
||||
|
||||
// parse all primitive that match the filter
|
||||
allWords.clear();
|
||||
allWords.reserve(100000);
|
||||
// to avoid duplicate
|
||||
set<string> allWordSet;
|
||||
for(uint i=0;i<allFiles.size();i++)
|
||||
{
|
||||
string fileName= CFile::getFilename(allFiles[i]);
|
||||
// filter don't match?
|
||||
bool oneMatch= false;
|
||||
for(uint filter=0;filter<PrimFilter.size();filter++)
|
||||
{
|
||||
if(testWildCard(fileName, PrimFilter[filter]))
|
||||
oneMatch= true;
|
||||
}
|
||||
if(!oneMatch)
|
||||
continue;
|
||||
|
||||
// ok, read the file
|
||||
CPrimitives PrimDoc;
|
||||
CPrimitiveContext::instance().CurrentPrimitive = &PrimDoc;
|
||||
// if (!loadXmlPrimitiveFile(PrimDoc, allFiles[i], LigoConfig))
|
||||
// {
|
||||
// nlwarning("Error: cannot open file '%s'. '%s' Aborted", allFiles[i].c_str(), workSheetFileName.c_str());
|
||||
// CPrimitiveContext::instance().CurrentPrimitive = NULL;
|
||||
// return false;
|
||||
// }
|
||||
CPrimitiveContext::instance().CurrentPrimitive = NULL;
|
||||
|
||||
// For all primitives of interest
|
||||
const char *listClass[]= {"continent", "region", "place", "stable",
|
||||
"teleport_destination", "room_template"};
|
||||
const char *listProp[]= {"name", "name", "name", "name",
|
||||
"place_name", "place_name"};
|
||||
const uint numListClass= sizeof(listClass)/sizeof(listClass[0]);
|
||||
const uint numListProp= sizeof(listProp)/sizeof(listProp[0]);
|
||||
nlctassert(numListProp==numListClass);
|
||||
for(uint cid=0;cid<numListClass;cid++)
|
||||
{
|
||||
// parse the whole hierarchy
|
||||
TPrimitiveClassPredicate predCont(listClass[cid]);
|
||||
CPrimitiveSet<TPrimitiveClassPredicate> setPlace;
|
||||
TPrimitiveSet placeRes;
|
||||
setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes);
|
||||
// for all found
|
||||
for (uint placeId= 0; placeId < placeRes.size(); ++placeId)
|
||||
{
|
||||
string primName;
|
||||
if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty())
|
||||
{
|
||||
primName= toLower(primName);
|
||||
// avoid duplicate
|
||||
if(allWordSet.insert(primName).second)
|
||||
{
|
||||
allWords.push_back(primName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
// 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/>.
|
||||
|
||||
#ifndef EXTRACT_NEW_SHEET_NAMES_H
|
||||
#define EXTRACT_NEW_SHEET_NAMES_H
|
||||
|
||||
#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/misc/algo.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;
|
||||
|
||||
namespace Plugin {
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/*
|
||||
* Interface to build the whole list of words (key id) for a specific worksheet
|
||||
*/
|
||||
struct IWordListBuilder
|
||||
{
|
||||
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName) =0;
|
||||
|
||||
};
|
||||
|
||||
struct CSheetWordListBuilder : public IWordListBuilder
|
||||
{
|
||||
string SheetExt;
|
||||
string SheetPath;
|
||||
|
||||
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName);
|
||||
};
|
||||
|
||||
struct CRegionPrimWordListBuilder : public IWordListBuilder
|
||||
{
|
||||
string PrimPath;
|
||||
vector<string> PrimFilter;
|
||||
virtual bool buildWordList(std::vector<string> &allWords, string workSheetFileName);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* EXTRACT_NEW_SHEET_NAMES_H */
|
||||
|
Loading…
Reference in New Issue