Improved messages

This commit is contained in:
Zane U. Ji 2014-03-24 19:11:15 +08:00
parent 19fded5473
commit 9826820285
4 changed files with 354 additions and 345 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ That's quite easy. Download Xml-copy-editor(called XCE below :P),
unpack it. Go to that source dirctory. Here you can see many ".cpp" unpack it. Go to that source dirctory. Here you can see many ".cpp"
files and ".h" files. input command: files and ".h" files. input command:
$ xgettext -k_ --from-code=utf-8 *.cpp *.h $ xgettext -k_ -kwxPLURAL:1,2 --from-code=utf-8 *.cpp *.h
then you get a "messages.po" in the dirctory. That's the ".po" file we then you get a "messages.po" in the dirctory. That's the ".po" file we
need to translate. You need a tool to help you finish the translation need to translate. You need a tool to help you finish the translation
@ -44,7 +44,7 @@ version. Uncompress the source and install poedit in "c:\poedit", then
open a "Command Window" by executing "cmd.exe". Go to the XCE's source open a "Command Window" by executing "cmd.exe". Go to the XCE's source
directory, run: directory, run:
c:\poedit\bin\xgettext.exe -k_ --from-code=utf-8 *.cpp *.h c:\poedit\bin\xgettext.exe -k_ -kwxPLURAL:1,2 --from-code=utf-8 *.cpp *.h
to a messages.po file. Setup poedit the same as in the Linux part, then to a messages.po file. Setup poedit the same as in the Linux part, then
open the ".po" file you just created and translate all items. When you open the ".po" file you just created and translate all items. When you

View File

@ -25,7 +25,6 @@
#endif #endif
#include "styledialog.h" #include "styledialog.h"
#include "nocasecompare.h" #include "nocasecompare.h"
#define ngettext wxGetTranslation
BEGIN_EVENT_TABLE ( StyleDialog, wxDialog ) BEGIN_EVENT_TABLE ( StyleDialog, wxDialog )
EVT_BUTTON ( ID_STYLE_REPORT, StyleDialog::OnReport ) EVT_BUTTON ( ID_STYLE_REPORT, StyleDialog::OnReport )
@ -508,7 +507,7 @@ void StyleDialog::OnReport ( wxCommandEvent& event )
++i; ++i;
} }
wxString message; wxString message;
message.Printf ( ngettext ( L"%i error", L"%i errors", i ), i ); message.Printf ( wxPLURAL ( "%i error", "%i errors", i ), i );
status->SetStatusText ( message ); status->SetStatusText ( message );
if ( i ) if ( i )
table->SetFocus(); table->SetFocus();

View File

@ -66,8 +66,6 @@
#include "dtd2schema.h" #include "dtd2schema.h"
#include "myipc.h" #include "myipc.h"
#define ngettext wxGetTranslation
#ifdef NEWFINDREPLACE #ifdef NEWFINDREPLACE
#include "findreplacepanel.h" #include "findreplacepanel.h"
#endif #endif
@ -2001,7 +1999,7 @@ void MyFrame::OnDialogReplaceAll ( wxFindDialogEvent& event )
wxString msg; wxString msg;
msg.Printf ( msg.Printf (
ngettext ( L"%i replacement made", L"%i replacements made", replacementCount ), wxPLURAL ( "%i replacement made", "%i replacements made", replacementCount ),
replacementCount ); replacementCount );
statusProgress ( msg ); statusProgress ( msg );
} }
@ -2802,7 +2800,7 @@ void MyFrame::OnGlobalReplace ( wxCommandEvent& event )
wxString msg; wxString msg;
msg.Printf ( msg.Printf (
ngettext ( L"%i replacement made", L"%i replacements made", globalMatchCount ), wxPLURAL ( "%i replacement made", "%i replacements made", globalMatchCount ),
globalMatchCount ); globalMatchCount );
statusProgress ( msg ); statusProgress ( msg );
@ -4869,7 +4867,7 @@ void MyFrame::displaySavedStatus ( int bytes )
else if ( bytes >= 0 ) else if ( bytes >= 0 )
{ {
result = bytes; result = bytes;
unit = ngettext ( L"byte", L"bytes", bytes ); unit = wxPLURAL ( "byte", "bytes", bytes );
} }
else else
return; return;
@ -5920,7 +5918,7 @@ void MyFrame::OnWordCount ( wxCommandEvent& event )
int count = xwc->getWordCount(); int count = xwc->getWordCount();
msg.Printf ( msg.Printf (
ngettext ( L"%s contains %i word", L"%s contains %i words", count ), wxPLURAL ( "%s contains %i word", "%s contains %i words", count ),
doc->getShortFileName().c_str(), count ); doc->getShortFileName().c_str(), count );
messagePane ( msg, CONST_INFO, true ); messagePane ( msg, CONST_INFO, true );
@ -6079,15 +6077,15 @@ void MyFrame::addToFileQueue ( wxString& fileName )
void MyFrame::validatePaths() void MyFrame::validatePaths()
{ {
bool valid = true; int invalid = 0;
wxString msg; wxString msg;
// Warning: Don't put a space between 'CHECK' and '(' // Warning: Don't put a space between 'CHECK' and '('
#define CHECK( check, path ) \ #define CHECK( check, path ) \
if ( !( check ) ( path ) )\ if ( !( check ) ( path ) )\
{\ {\
valid = false;\ invalid++;\
msg << _ ( "Invalid path: " ) << path << wxTextFile::GetEOL();\ msg << wxTextFile::GetEOL() << path;\
} }
CHECK ( wxDirExists, ruleSetDir ); CHECK ( wxDirExists, ruleSetDir );
//CHECK ( wxDirExists, filterDir ); //CHECK ( wxDirExists, filterDir );
@ -6110,10 +6108,12 @@ void MyFrame::validatePaths()
#endif // __WXMSW__ #endif // __WXMSW__
#undef CHECK #undef CHECK
if ( valid ) if ( !invalid )
return; return;
msg = wxPLURAL ( "Invalid path: ", "Invalid paths: ", invalid ) + msg;
msg << wxTextFile::GetEOL() msg << wxTextFile::GetEOL()
<< wxTextFile::GetEOL()
#ifdef __WXMSW__ #ifdef __WXMSW__
<< _ ( "To change application directory, see Tools, Options..., General" ); << _ ( "To change application directory, see Tools, Options..., General" );
#else #else