[pgadmin-hackers] Patch for plural forms

2009-06-10 Thread Marek Černocký
I write patch for plural forms of translated texts. It solves second
problem from report by Heikki:

http://archives.postgresql.org/pgadmin-hackers/2009-05/msg00017.php

It use wxPLURAL instead _. I also change stringextract script to
know this. Following steps required when patche is aplied:
- regenerate POT template
- merge it with PO files
PO files must have set Plural-Forms correctly, e.g. for czech it si:
Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n=2  n=4) ? 1 : 2;
\n
You can find it in gettext documentation (section 10.2.5) or create new
PO file from POT by msginit with appropriate param -l.

Marek
diff -r -c pgadmin3.svn/pgadmin/ctl/ctlSQLBox.cpp pgadmin3.new/pgadmin/ctl/ctlSQLBox.cpp
*** pgadmin3.svn/pgadmin/ctl/ctlSQLBox.cpp	2009-06-10 11:04:52.0 +0200
--- pgadmin3.new/pgadmin/ctl/ctlSQLBox.cpp	2009-06-10 11:32:17.0 +0200
***
*** 192,198 
  GotoPos(initialPos);
  
  wxString msg;
! msg.Printf(_(%d replacements made.), count);
  wxMessageBox(msg, _(Replace all));
  
  if (count)
--- 192,198 
  GotoPos(initialPos);
  
  wxString msg;
! msg.Printf(wxPLURAL(%d replacement made., %d replacements made., count), count);
  wxMessageBox(msg, _(Replace all));
  
  if (count)
diff -r -c pgadmin3.svn/pgadmin/db/pgQueryThread.cpp pgadmin3.new/pgadmin/db/pgQueryThread.cpp
*** pgadmin3.svn/pgadmin/db/pgQueryThread.cpp	2009-06-10 11:05:04.0 +0200
--- pgadmin3.new/pgadmin/db/pgQueryThread.cpp	2009-06-10 12:24:14.0 +0200
***
*** 145,158 
  insertedOid=PQoidValue(res);
  if (insertedOid  insertedOid != (OID)-1)
  appendMessage(wxString::Format(_(Query inserted one row with OID %d.\n), insertedOid));
! 			else
! appendMessage(wxString::Format(_(Query result with %d rows will be returned.\n), PQntuples(result)));
  continue;
  }
  if (lastResult)
  {
  if (PQntuples(lastResult))
! appendMessage(wxString::Format(_(Query result with %d rows discarded.\n), PQntuples(lastResult)));
  PQclear(lastResult);
  }
  lastResult=res;
--- 145,160 
  insertedOid=PQoidValue(res);
  if (insertedOid  insertedOid != (OID)-1)
  appendMessage(wxString::Format(_(Query inserted one row with OID %d.\n), insertedOid));
! else
! appendMessage(wxString::Format(wxPLURAL(Query result with %d row will be returned.\n, Query result with %d rows will be returned.\n, 
! PQntuples(result)), PQntuples(result)));
  continue;
  }
  if (lastResult)
  {
  if (PQntuples(lastResult))
! appendMessage(wxString::Format(wxPLURAL(Query result with %d row discarded.\n, Query result with %d rows discarded.\n, 
! PQntuples(lastResult)), PQntuples(lastResult)));
  PQclear(lastResult);
  }
  lastResult=res;
diff -r -c pgadmin3.svn/pgadmin/frm/frmEditGrid.cpp pgadmin3.new/pgadmin/frm/frmEditGrid.cpp
*** pgadmin3.svn/pgadmin/frm/frmEditGrid.cpp	2009-06-10 11:05:04.0 +0200
--- pgadmin3.new/pgadmin/frm/frmEditGrid.cpp	2009-06-10 12:31:40.0 +0200
***
*** 387,393 
  if (limit = 0)
  cbLimit-SetValue(_(No limit));
  else
! cbLimit-SetValue(wxString::Format(_(%i rows), limit));
  }
  }
  
--- 387,393 
  if (limit = 0)
  cbLimit-SetValue(_(No limit));
  else
! cbLimit-SetValue(wxString::Format(wxPLURAL(%i row, %i rows, limit), limit));
  }
  }
  
***
*** 668,674 
  {
  int copied;
  copied = sqlGrid-Copy();
! SetStatusText(wxString::Format(_(Data from %d rows copied to clipboard.), copied));
  }
  }
  }
--- 668,676 
  {
  int copied;
  copied = sqlGrid-Copy();
! SetStatusText(wxString::Format(
! wxPLURAL(Data from %d row copied to clipboard., Data from %d rows copied to clipboard., copied), 
! copied));
  }
  }
  }
***
*** 1062,1071 
  return;
  
  wxString prompt;
! if (i == 1)
! prompt.Printf(_(Are you sure you wish to delete the selected row?));
! else
! prompt.Printf(_(Are you sure you wish to delete the %d selected rows?), i);
  
  wxMessageDialog msg(this, prompt, _(Delete rows?), wxYES_NO | wxICON_QUESTION);
  if (msg.ShowModal() != wxID_YES)
--- 1064,1070 
  return;
  
  wxString prompt;
! prompt.Printf(wxPLURAL(Are you sure you wish to delete the selected row?, Are you sure you wish to delete the %d selected rows?, i));
  
  wxMessageDialog msg(this, prompt, _(Delete rows?), wxYES_NO | wxICON_QUESTION);
  if (msg.ShowModal() != wxID_YES)

Re: [pgadmin-hackers] Patch for plural forms

2009-06-10 Thread Dave Page
2009/6/10 Marek Černocký ma...@manet.cz:
 I write patch for plural forms of translated texts. It solves second
 problem from report by Heikki:

 http://archives.postgresql.org/pgadmin-hackers/2009-05/msg00017.php

 It use wxPLURAL instead _. I also change stringextract script to
 know this. Following steps required when patche is aplied:
 - regenerate POT template
 - merge it with PO files
 PO files must have set Plural-Forms correctly, e.g. for czech it si:
 Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n=2  n=4) ? 1 : 2;
 \n
 You can find it in gettext documentation (section 10.2.5) or create new
 PO file from POT by msginit with appropriate param -l.

Thanks - I've added your patch to the ticket at
http://code.pgadmin.org/trac/ticket/4

Unfortunately it's too late for 1.10.

-- 
Dave Page
EnterpriseDB UK:   http://www.enterprisedb.com

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers