Work with translated files, instead of work files.

This commit is contained in:
dfighter1985 2014-07-20 17:24:04 +02:00
parent b0c916276d
commit a51f76d036
3 changed files with 43 additions and 15 deletions

View file

@ -54,6 +54,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_ui.mdiArea->closeAllSubWindows(); _ui.mdiArea->closeAllSubWindows();
windowMapper = new QSignalMapper(this); windowMapper = new QSignalMapper(this);
m_UXTMapper = new QSignalMapper(this);
connect(windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(setActiveSubWindow(QWidget *))); connect(windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(setActiveSubWindow(QWidget *)));
initialize_settings["georges"] = false; initialize_settings["georges"] = false;
@ -87,8 +88,20 @@ void CMainWindow::createMenus()
{ {
windowMenu = m->addMenu("Window"); windowMenu = m->addMenu("Window");
QAction *a = m->addAction( "Uxt" ); QMenu *mm = m->addMenu( "UI translation" );
connect( a, SIGNAL( triggered() ), this, SLOT( onUxtClicked() ) ); 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; menu = m;
} }
@ -550,9 +563,9 @@ 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( "\\", "/" ); path.replace( "\\", "/" );
if( getEditorByWindowFilePath( path ) != NULL ) if( getEditorByWindowFilePath( path ) != NULL )

View file

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

View file

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