Work with translated files, instead of work files.

--HG--
branch : gsoc2014-dfighter
hg/feature/cdb-packed
dfighter1985 10 years ago
parent fbcfa4ee6f
commit 2c812e90ab

@ -54,6 +54,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_ui.mdiArea->closeAllSubWindows();
windowMapper = new QSignalMapper(this);
m_UXTMapper = new QSignalMapper(this);
connect(windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(setActiveSubWindow(QWidget *)));
initialize_settings["georges"] = false;
@ -87,8 +88,20 @@ void CMainWindow::createMenus()
{
windowMenu = m->addMenu("Window");
QAction *a = m->addAction( "Uxt" );
connect( a, SIGNAL( triggered() ), this, SLOT( onUxtClicked() ) );
QMenu *mm = m->addMenu( "UI translation" );
if( mm != NULL )
{
QStringListIterator itr( languages );
while( itr.hasNext() )
{
QString lang = itr.next();
QAction *a = mm->addAction( lang );
connect( a, SIGNAL( triggered() ), m_UXTMapper, SLOT( map() ) );
m_UXTMapper->setMapping( a, lang );
}
connect( m_UXTMapper, SIGNAL( mapped( QString ) ), this, SLOT( onUxtMapped( QString ) ) );
}
menu = m;
}
@ -550,14 +563,14 @@ void CMainWindow::mergeSingleFile()
}
}
void CMainWindow::onUxtClicked()
void CMainWindow::onUxtMapped( QString lang )
{
QString path = work_path + "/" + QString( Constants::WK_UXT );
QString path = translation_path + "/" + lang + ".uxt";
path.replace( "\\", "/" );
if( getEditorByWindowFilePath( path ) != NULL )
return;
UXTEditor *e = new UXTEditor();
e->open( path );
e->setCurrentFile( path );

@ -71,6 +71,7 @@ private:
QAction *saveAsAct;
QMenu *windowMenu;
QSignalMapper *windowMapper;
QSignalMapper *m_UXTMapper;
// config
QMap<string,bool> initialize_settings;
QList<QString> filters;
@ -90,7 +91,7 @@ private Q_SLOTS:
void setActiveSubWindow(QWidget *window);
void updateWindowsList();
void mergeSingleFile();
void onUxtClicked();
void onUxtMapped( QString lang );
private:
void openWorkFile(QString file);

@ -29,6 +29,7 @@
#include <QTextStream>
#include "nel/misc/diff_tool.h"
#include "nel/misc/i18n.h"
namespace TranslationManager
{
@ -120,23 +121,36 @@ void UXTEditor::saveAs( QString filename )
QTextStream out( &f );
int idx = 0;
std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin();
while( itr != d_ptr->infos.end() )
{
QString line = "";
QString hashLine = "// HASH_VALUE ";
hashLine += QString( NLMISC::CI18N::hashToString( itr->HashValue ).c_str() ).toUpper();
hashLine += "\r\n";
line += itr->Identifier.c_str();
line += "\t";
QString idxLine = "// INDEX ";
idxLine += QString::number( idx );
idxLine += "\r\n";
line += "[";
line += itr->Text.toUtf8().c_str();
line += "]";
QString trLine = "";
trLine += itr->Identifier.c_str();
trLine += "\t";
trLine += "[";
trLine += itr->Text.toUtf8().c_str();
trLine += "]";
trLine += "\r\n";
line += "\r\n";
QString newLine = "\r\n";
out << line;
out << hashLine;
out << idxLine;
out << trLine;
out << newLine;
++itr;
idx++;
}
f.close();

Loading…
Cancel
Save