From fd36c7676bd72d0905a90107e05cd67c1933c746 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 20 Jul 2014 17:24:04 +0200 Subject: [PATCH] Work with translated files, instead of work files. --- .../translation_manager_main_window.cpp | 25 ++++++++++++---- .../translation_manager_main_window.h | 3 +- .../translation_manager/uxt_editor.cpp | 30 ++++++++++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp index aafc6f473..b439edce6 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.cpp @@ -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 ); diff --git a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h index ba6ce8746..34f60ff19 100644 --- a/code/studio/src/plugins/translation_manager/translation_manager_main_window.h +++ b/code/studio/src/plugins/translation_manager/translation_manager_main_window.h @@ -71,6 +71,7 @@ private: QAction *saveAsAct; QMenu *windowMenu; QSignalMapper *windowMapper; + QSignalMapper *m_UXTMapper; // config QMap initialize_settings; QList 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); diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.cpp b/code/studio/src/plugins/translation_manager/uxt_editor.cpp index 4004c05e4..9f8cc56f4 100644 --- a/code/studio/src/plugins/translation_manager/uxt_editor.cpp +++ b/code/studio/src/plugins/translation_manager/uxt_editor.cpp @@ -29,6 +29,7 @@ #include #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();