GNOME Bugzilla – Bug 117147
gtranslator doesn't open po-files with plural forms
Last modified: 2009-08-15 18:40:50 UTC
Try to open the following sample in gtranslator. The program will claim an error in line 17, probably because of the use of a msgid_plural string. msgid "" msgstr "" "Project-Id-Version: de\n" "POT-Creation-Date: 2003-06-17 16:41-0400\n" "PO-Revision-Date: 2003-07-04 06:32+0200\n" "Last-Translator: Frank Ellebrecht <ellebrecht-edv(at)gmx.de>\n" "Language-Team: None\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" #: src/liflines/add.c:62 #, c-format msgid "There was %d unresolved reference." msgid_plural "There were %d unresolved references." msgstr[0] "%d Datensatz mit diesem Schlüssel oder Bezug gibt es nicht." msgstr[1] "%d Datensätze mit diesem Schlüssel oder Bezug gibt es nicht."
*** Bug 113960 has been marked as a duplicate of this bug. ***
Well, here we need to have a tactic or logic or something like that to get this going - one easy, cracking and stupido method came into my mind with which one could get this working: We could parse the msgid and then if the msgid_plural follows we could make the original GtrMsg->msgid string a "string container" for both of the strings with a simple separator between the two messages like a non used string part like EAT_MORE_CHICKEN or alike ;-) Then the same could be also done for the msgstr parts so that the parsed entries would look for gtranslator in the GtrMsg structure like that according to the above delivered example message: msgid "There was %d unresolved reference." msgid_plural "There were %d unresolved references." Gets -> GtrMsg->msgid="There was %d unresolved reference.EAT_MORE_CHICKENThere were %d unresolved references.". The same then for the msgstr, it's crapped and would require some grater changes in the source; another way would be to change the parse routines but then to define a new attr for GtrMsg like "group" or such to group the together bound messages together like: GtrMsg 1 -> msgid = There was %d unresolved reference. GtrMsg 1 -> group = 1 GtrMsg 2 -> msgid = There were %d unresolved references. GtrMsg 2 -> group = 1 GtrMsg 3 -> msgid = Whatever comes here... So it would be possible after building the msgid correspondingly in the parsing routines to get the messages also alltogether while saving to make the work of the translators good. Any comments, desires hints?! /me would vote for way #2 here...
Ah well, what I did forget - in the GUI the messages would look like different messages (group 1 would representate then 2 messages) but this logic has got one big disadvantage - for messages with more then just 2 translations (like in Polnish AFAIR) this would make the resting msgstr parts useless and got forgotten about them :-( Hmm...
First, the GtrMsg struct needs to be changed to accomodate plural records. I suggest that we add 'gchar *msgplural' under 'gchar *msgid', and convert 'gchar *msgstr' to 'glist *msgstrs' or something. Normal messages would only occupy one element of the list, and 'gboolean is_plural = (msgplural != NULL)'. Next, the parser need to be updated to read and write with the updated GtrMsg. This wouldn't be too hard. The hardest bit, for me anyway, would be designing the most appropriate GUI way to present singular and plural messages to the user for editting. Just my thoughts, in brief. -- Ross
This means we add: gchar *msgid_plural; GList *msgstrs; Making for normal messages the msgid_plural=NULL and the 1st msgstrs entry the default msgstr from today. For the GUI, the best approach would be to display the different translations as different messsages; or: a table with the translations where you can Add/Delete additional translations for the different counts like WINDOW--------------------------------------------------------------- Message---------------------------------------------------------frame Single | msgid Plural | msgid_plural Translation-----------------------------------------------------frame Translation # 0 | msgstr[0] 1 | msgstr[1] etc... with [Add] [Edit] [Delete] [Close] buttons. Would mean slower editing of such messages but maybe a more beautiful handling of these messages On [Edit] we could display the messsage in the normal GUI for editing.
Created attachment 18848 [details] The test case from Frank in a new, ext. UTF-8 version for testing issues
Fixed in CVS and the latest CVS Debian snapshots, the plural forms are now parsed, saved and displayed with a special dialog. You can even edit the plural forms. The implementation is a bit old-styled code but I guess most languages will stick with msgstr_2 as the maximum # of plural forms so that gtranslator should be good with that now :-) A (end-august) coming R 1.0 will solve this issue...