Commit de1f1f8f authored by Michael Reeves's avatar Michael Reeves

Finish port away from custom translator.

Windows shell extension now uses ki18n for translation rather than ship our
own manual attempt at it. This is a tier1 library so it doesn't drag in other
dependencies. Qt will also be needed.
parent f8e608c4
...@@ -35,34 +35,6 @@ ...@@ -35,34 +35,6 @@
#include <map> #include <map>
#include <vector> #include <vector>
static void replaceArgs( tstring& s, const tstring& r1, const tstring& r2=TEXT(""), const tstring& r3=TEXT("") )
{
tstring arg1 = TEXT("%1");
size_t pos1 = s.find( arg1 );
tstring arg2 = TEXT("%2");
size_t pos2 = s.find( arg2 );
tstring arg3 = TEXT("%3");
size_t pos3 = s.find( arg3 );
if ( pos1 != size_t(-1) )
{
s.replace( pos1, arg1.length(), r1 );
if ( pos2 != size_t(-1) && pos1<pos2 )
pos2 += r1.length() - arg1.length();
if ( pos3 != size_t(-1) && pos1<pos3 )
pos3 += r1.length() - arg1.length();
}
if ( pos2 != size_t(-1) )
{
s.replace( pos2, arg2.length(), r2 );
if ( pos3 != size_t(-1) && pos2<pos3 )
pos3 += r2.length() - arg2.length();
}
if ( pos3 != size_t(-1) )
{
s.replace( pos3, arg3.length(), r3 );
}
}
DIFF_EXT::DIFF_EXT() DIFF_EXT::DIFF_EXT()
: m_nrOfSelectedFiles(0), _ref_count(0L), : m_nrOfSelectedFiles(0), _ref_count(0L),
m_recentFiles( SERVER::instance()->recent_files() ) m_recentFiles( SERVER::instance()->recent_files() )
...@@ -258,11 +230,10 @@ DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*las ...@@ -258,11 +230,10 @@ DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*las
// tstring firstFileName = cut_to_length( m_recentFiles.front() ); // tstring firstFileName = cut_to_length( m_recentFiles.front() );
// tstring secondFileName = cut_to_length( *(++m_recentFiles.begin()) ); // tstring secondFileName = cut_to_length( *(++m_recentFiles.begin()) );
//} //}
m_id_Merge3 = insertMenuItemHelper( subMenu, id++, pos2++, i18n("3-way merge with base"), m_id_Merge3 = insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("3-way merge with base")),
nrOfRecentFiles >=2 ? MFS_ENABLED : MFS_DISABLED ); nrOfRecentFiles >=2 ? MFS_ENABLED : MFS_DISABLED );
menuString = i18n("Save '%1' for later"); menuString = fromQString(i18n("Save '%1' for later").arg(toQString(_file_name1)));
replaceArgs( menuString, _file_name1 );
m_id_DiffLater = insertMenuItemHelper( subMenu, id++, pos2++, menuString ); m_id_DiffLater = insertMenuItemHelper( subMenu, id++, pos2++, menuString );
HMENU file_list = CreateMenu(); HMENU file_list = CreateMenu();
...@@ -276,25 +247,25 @@ DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*las ...@@ -276,25 +247,25 @@ DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*las
++n; ++n;
} }
insertMenuItemHelper( subMenu, id++, pos2++, i18n("Compare with ..."), insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("Compare with ...")),
nrOfRecentFiles > 0 ? MFS_ENABLED : MFS_DISABLED, file_list ); nrOfRecentFiles > 0 ? MFS_ENABLED : MFS_DISABLED, file_list );
m_id_ClearList = insertMenuItemHelper( subMenu, id++, pos2++, i18n("Clear list"), nrOfRecentFiles >=1 ? MFS_ENABLED : MFS_DISABLED ); m_id_ClearList = insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("Clear list")), nrOfRecentFiles >=1 ? MFS_ENABLED : MFS_DISABLED );
} }
else if(m_nrOfSelectedFiles == 2) else if(m_nrOfSelectedFiles == 2)
{ {
//= "Diff " + cut_to_length(_file_name1, 20)+" and "+cut_to_length(_file_name2, 20); //= "Diff " + cut_to_length(_file_name1, 20)+" and "+cut_to_length(_file_name2, 20);
m_id_Diff = insertMenuItemHelper( subMenu, id++, pos2++, i18n("Compare") ); m_id_Diff = insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("Compare")) );
} }
else if ( m_nrOfSelectedFiles == 3 ) else if ( m_nrOfSelectedFiles == 3 )
{ {
m_id_Diff3 = insertMenuItemHelper( subMenu, id++, pos2++, i18n("3 way comparison") ); m_id_Diff3 = insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("3 way comparison")) );
} }
else else
{ {
// More than 3 files selected? // More than 3 files selected?
} }
m_id_About = insertMenuItemHelper( subMenu, id++, pos2++, i18n("About Diff-Ext ...") ); m_id_About = insertMenuItemHelper( subMenu, id++, pos2++, fromQString(i18n("About Diff-Ext ...")) );
insertMenuItemHelper( menu, id++, position++, TEXT("KDiff3"), MFS_ENABLED, subMenu ); insertMenuItemHelper( menu, id++, position++, TEXT("KDiff3"), MFS_ENABLED, subMenu );
...@@ -365,14 +336,13 @@ DIFF_EXT::InvokeCommand(LPCMINVOKECOMMANDINFO ici) ...@@ -365,14 +336,13 @@ DIFF_EXT::InvokeCommand(LPCMINVOKECOMMANDINFO ici)
else if(id == m_id_About) else if(id == m_id_About)
{ {
LOG(); LOG();
std::wstring sBits = i18n("(32 Bit)"); QString sBits = i18n("(32 Bit)");
if (sizeof(void*)==8) if (sizeof(void*)==8)
sBits = i18n("(64 Bit)"); MessageBox( _hwnd, (fromQString(i18n("Diff-Ext Copyright (c) 2003-2006, Sergey Zorin. All rights reserved.\n")
MessageBox( _hwnd, (i18n("Diff-Ext Copyright (c) 2003-2006, Sergey Zorin. All rights reserved.\n")
+ i18n("This software is distributable under the BSD-2-Clause license.\n") + i18n("This software is distributable under the BSD-2-Clause license.\n")
+ i18n("Some extensions for KDiff3 (c) 2006-2013 by Joachim Eibl.\n") + i18n("Some extensions for KDiff3 (c) 2006-2013 by Joachim Eibl.\n")
+ i18n("Homepage for Diff-Ext: http://diff-ext.sourceforge.net\n")).c_str() + i18n("Homepage for Diff-Ext: http://diff-ext.sourceforge.net\n"))).c_str()
, (i18n("About Diff-Ext for KDiff3 ")+sBits).c_str(), MB_OK ); , fromQString(i18n("About Diff-Ext for KDiff3 ")+sBits).c_str(), MB_OK );
} }
else else
{ {
...@@ -398,7 +368,7 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI ...@@ -398,7 +368,7 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI
HRESULT ret = NOERROR; HRESULT ret = NOERROR;
if(uFlags == GCS_HELPTEXT) { if(uFlags == GCS_HELPTEXT) {
tstring helpString; QString helpString;
if( idCmd == m_id_Diff ) if( idCmd == m_id_Diff )
{ {
helpString = i18n("Compare selected files"); helpString = i18n("Compare selected files");
...@@ -407,14 +377,12 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI ...@@ -407,14 +377,12 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI
{ {
if(!m_recentFiles.empty()) if(!m_recentFiles.empty())
{ {
helpString = i18n("Compare '%1' with '%2'"); helpString = i18n("Compare '%1' with '%2'").arg(toQString(_file_name1), toQString(m_recentFiles.front()));
replaceArgs( helpString, _file_name1, m_recentFiles.front() );
} }
} }
else if(idCmd == m_id_DiffLater) else if(idCmd == m_id_DiffLater)
{ {
helpString = i18n("Save '%1' for later operation"); helpString = i18n("Save '%1' for later operation").arg(_file_name1);
replaceArgs( helpString, _file_name1 );
} }
else if((idCmd >= m_id_DiffWith_Base) && (idCmd < m_id_DiffWith_Base+m_recentFiles.size())) else if((idCmd >= m_id_DiffWith_Base) && (idCmd < m_id_DiffWith_Base+m_recentFiles.size()))
{ {
...@@ -427,12 +395,11 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI ...@@ -427,12 +395,11 @@ DIFF_EXT::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT*, LPSTR pszName, UI
if ( i!=m_recentFiles.end() ) if ( i!=m_recentFiles.end() )
{ {
helpString = i18n("Compare '%1' with '%2'"); helpString = i18n("Compare '%1' with '%2'").arg(toQString(_file_name1), toQString(*i));
replaceArgs( helpString, _file_name1, *i );
} }
} }
} }
lstrcpyn( (LPTSTR)pszName, helpString.c_str(), cchMax ); lstrcpyn( (LPTSTR)pszName, fromQString(helpString).c_str(), cchMax );
} }
else else
{ {
...@@ -469,10 +436,10 @@ DIFF_EXT::diff( const tstring& arguments ) ...@@ -469,10 +436,10 @@ DIFF_EXT::diff( const tstring& arguments )
if (bError) if (bError)
{ {
tstring message = i18n("Could not start KDiff3. Please rerun KDiff3 installation."); tstring message = fromQString(i18n("Could not start KDiff3. Please rerun KDiff3 installation."));
message += TEXT("\n") + i18n("Command") + TEXT(": ") + command; message += TEXT("\n") + fromQString(i18n("Command")) + TEXT(": ") + command;
message += TEXT("\n") + i18n("CommandLine") + TEXT(": ") + commandLine; message += TEXT("\n") + fromQString(i18n("CommandLine")) + TEXT(": ") + commandLine;
MessageBox(_hwnd, message.c_str(), i18n("Diff-Ext For KDiff3").c_str(), MB_OK); MessageBox(_hwnd, message.c_str(), fromQString(i18n("Diff-Ext For KDiff3")).c_str(), MB_OK);
} }
} }
......
...@@ -31,9 +31,18 @@ ...@@ -31,9 +31,18 @@
#include <string> // std::wstring #include <string> // std::wstring
#ifdef UNICODE #ifdef UNICODE
typedef std::wstring tstring; typedef std::wstring tstring;
#define toQString(s) QString::fromStdWString(s)
#define fromQString(s) (s).toStdWString()
#else #else
typedef std::string tstring; typedef std::string tstring;
#define toQString(s) { QString::fromStdString(s);}
#define fromQString(s) { (s).toStdString();}
#endif #endif
#define MESSAGELOG( msg ) SERVER::logMessage( __FUNCTION__, __FILE__, __LINE__, msg ) #define MESSAGELOG( msg ) SERVER::logMessage( __FUNCTION__, __FILE__, __LINE__, msg )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment