[orca] Fix for bug #626272 -Plural forms needed for correct localization



commit f4915a2e3775a6b97d93b61c4c7cdb7d8140f2b2
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Aug 13 21:30:47 2010 -0400

    Fix for bug #626272 -Plural forms needed for correct localization

 src/orca/flat_review.py                            |    6 ++++-
 src/orca/orca.py                                   |   15 +++++++----
 src/orca/scripts/apps/acroread/script.py           |   15 +++++++++--
 src/orca/scripts/apps/soffice/script.py            |   18 ++++++++++---
 .../scripts/toolkits/Gecko/speech_generator.py     |    5 +++-
 src/orca/speech_generator.py                       |    4 ++-
 src/orca/structural_navigation.py                  |   26 +++++++++++++------
 test/keystrokes/oowriter/bug_382408.py             |    6 ++--
 test/keystrokes/oowriter/bug_382415.py             |    6 ++--
 test/keystrokes/oowriter/bug_382418.py             |    6 ++--
 test/keystrokes/oowriter/bug_382880.py             |    6 ++--
 test/keystrokes/oowriter/bug_382888.py             |    6 ++--
 test/keystrokes/oowriter/table_cells.py            |    6 ++--
 .../oowriter/table_cells_structural_navigation1.py |    6 ++--
 14 files changed, 87 insertions(+), 44 deletions(-)
---
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index 634bc3c..5fc75c2 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -37,6 +37,7 @@ import settings
 
 from orca_i18n import _         # for gettext support
 from orca_i18n import C_        # to provide qualified translatable strings
+from orca_i18n import ngettext
 
 # [[[WDW - HACK Regular expression to split strings on whitespace
 # boundaries, which is what we'll use for word dividers instead of
@@ -443,7 +444,10 @@ class ValueZone(Zone):
             # progress bar or other component that displays a value as 
             # a percentage.
             #
-            speechValue = speechValue + " " + _("%d percent.") % percentValue
+            percentString = ngettext("%d percent.",
+                                     "%d percent.",
+                                     percentValue) % percentValue
+            speechValue = speechValue + " " + percentString
 
             if orientation:
                 brailleValue = "%s %s %d%%" % (orientation,
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 6397784..8a139e2 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -91,6 +91,7 @@ from input_event import MouseButtonEvent
 from input_event import keyEventToString
 
 from orca_i18n import _           # for gettext support
+from orca_i18n import ngettext
 
 if settings.debugMemoryUsage:
     import gc
@@ -1339,7 +1340,9 @@ def listShortcuts(event):
             # 'list of shortcuts mode'. In this messsage, we present the
             # number of shortcuts found.
             #
-            message = _("%d Orca default shortcuts found.") % numShortcuts
+            message = ngettext("%d Orca default shortcut found.",
+                               "%d Orca default shortcuts found.",
+                               numShortcuts) % numShortcuts
             message = message + " " + navigation
             orca_state.activeScript.presentMessage(message)
             message = orca_state.listOfShortcuts[orca_state.ptrToShortcut][0]+ \
@@ -1358,10 +1361,12 @@ def listShortcuts(event):
                 # 'list of shortcuts mode'. In this message, we present the
                 # number of shortcuts found for the named application.
                 #
-                message = \
-                    _("%(count)d Orca shortcuts for %(application)s found.") % \
-                     {"count" : numShortcuts,
-                      "application" : orca_state.activeScript.app.name}
+                message = ngettext( \
+                    "%(count)d Orca shortcut for %(application)s found.",
+                    "%(count)d Orca shortcuts for %(application)s found.",
+                    numShortcuts) % \
+                    {"count" : numShortcuts,
+                     "application" : orca_state.activeScript.app.name}
                 message = message + " " + navigation
                 orca_state.activeScript.presentMessage(message)
                 message = \
diff --git a/src/orca/scripts/apps/acroread/script.py b/src/orca/scripts/apps/acroread/script.py
index eb6a001..82cfee8 100644
--- a/src/orca/scripts/apps/acroread/script.py
+++ b/src/orca/scripts/apps/acroread/script.py
@@ -37,6 +37,7 @@ import orca.settings as settings
 import orca.speech as speech
 
 from orca.orca_i18n import _ # for gettext support
+from orca.orca_i18n import ngettext
 
 ########################################################################
 #                                                                      #
@@ -270,10 +271,18 @@ class Script(default.Script):
         # need to detect this and adjust accordingly.]]]
 
         if not oldFocusIsTable and newFocusIsTable:
-            # We've entered a table.  Announce the dimensions.
+            # Translators: this represents the number of rows in a table.
             #
-            line = _("table with %(rows)d rows and %(columns)d columns.") \
-                   % {"rows" : newFocusRows, "columns" : newFocusColumns}
+            rowString = ngettext("table with %d row",
+                                 "table with %d rows",
+                                 newFocusRows) % newFocusRows
+            # Translators: this represents the number of columns in a table.
+            #
+            colString = ngettext("%d column",
+                                 "%d columns",
+                                 newFocusColumns) % newFocusColumns
+
+            line = rowString + " " + colString
             self.presentMessage(line)
 
         elif oldFocusIsTable and not newFocusIsTable:
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index c86044f..75526bd 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -49,6 +49,7 @@ import orca.speech as speech
 import orca.settings as settings
 
 from orca.orca_i18n import _ # for gettext support
+from orca.orca_i18n import ngettext
 
 from speech_generator import SpeechGenerator
 from braille_generator import BrailleGenerator
@@ -723,11 +724,20 @@ class Script(default.Script):
                 #
                 self.presentMessage(_("leaving table."))
             if newTable:
-                # We've entered a table.  Announce the dimensions.
+                nRows = newTable.nRows
+                nColumns = newTable.nColumns
+                # Translators: this represents the number of rows in a table.
                 #
-                line = _("table with %(rows)d rows and %(columns)d columns.") \
-                       % {"rows" : newTable.nRows,
-                          "columns" : newTable.nColumns}
+                rowString = ngettext("table with %d row",
+                                     "table with %d rows",
+                                     nRows) % nRows
+                # Translators: this represents the number of columns in a table.
+                #
+                colString = ngettext("%d column",
+                                     "%d columns",
+                                     nColumns) % nColumns
+
+                line = rowString + " " + colString
                 self.presentMessage(line)
 
         if not newTable:
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index f4669c4..27ab914 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -484,7 +484,10 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             # current position divided by the total number of objects on the
             # page.
             #
-            result.append(_('%d percent of document read') % percent)
+            result.append(ngettext \
+                ('%d percent of document read',
+                 '%d percent of document read',
+                 percent) % percent)
 
         return result
 
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 4181028..01bed32 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -991,7 +991,9 @@ class SpeechGenerator(generator.Generator):
                 * 100.0
             # Translators: this is the percentage value of a progress bar.
             #
-            percentage = _("%d percent") % percentValue
+            percentage = ngettext("%d percent",
+                                  "%d percent",
+                                  percentValue) % percentValue
             result.append(percentage)
         return result
 
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index 640ad85..0174f29 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -1335,10 +1335,10 @@ class StructuralNavigation:
         nColumns = table.nColumns
         # Translators: this represents the number of rows in a table.
         #
-        rowString = ngettext("Table with %d row",
-                             "Table with %d rows",
+        rowString = ngettext("table with %d row",
+                             "table with %d rows",
                              nRows) % nRows
-        # Translators: this represents the number of cols in a table.
+        # Translators: this represents the number of columns in a table.
         #
         colString = ngettext("%d column",
                              "%d columns",
@@ -1490,26 +1490,36 @@ class StructuralNavigation:
         rowspan = table.getRowExtentAt(row, col)
         colspan = table.getColumnExtentAt(row, col)
         spanString = ""
+        # Translators: this represents the number of rows in a table.
+        #
+        rowString = ngettext("%d row",
+                             "%d rows",
+                             rowspan) % rowspan
+        # Translators: this represents the number of columns in a table.
+        #
+        colString = ngettext("%d column",
+                             "%d columns",
+                             colspan) % colspan
         if (colspan > 1) and (rowspan > 1):
             # Translators: The cell here refers to a cell within a table
             # within a document.  We need to announce when the cell occupies
             # or "spans" more than a single row and/or column.
             #
-            spanString = _("Cell spans %(rows)d rows and %(columns)d columns") \
-                         % {"rows" : rowspan,
-                            "columns" : colspan}
+            spanString = _("Cell spans %(rows)s and %(columns)s") \
+                         % {"rows" : rowString,
+                            "columns" : colString}
         elif (colspan > 1):
             # Translators: The cell here refers to a cell within a table
             # within a document.  We need to announce when the cell occupies
             # or "spans" more than a single row and/or column.
             #
-            spanString = _("Cell spans %d columns") % colspan
+            spanString = _("Cell spans %s") % colString
         elif (rowspan > 1):
             # Translators: The cell here refers to a cell within a table
             # within a document.  We need to announce when the cell occupies
             # or "spans" more than a single row and/or column.
             #
-            spanString = _("Cell spans %d rows") % rowspan
+            spanString = _("Cell spans %s") % rowString
 
         return spanString
 
diff --git a/test/keystrokes/oowriter/bug_382408.py b/test/keystrokes/oowriter/bug_382408.py
index 1e8ec1e..fa89803 100644
--- a/test/keystrokes/oowriter/bug_382408.py
+++ b/test/keystrokes/oowriter/bug_382408.py
@@ -51,11 +51,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "Type a down arrow to move to the Mon table column header",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Sun Mon Tue Wed Thu Fri Sat") + "'",
      "     VISIBLE:  'Mon Tue Wed Thu Fri Sat', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Sun Mon Tue Wed Thu Fri Sat'"]))
 
 ######################################################################
diff --git a/test/keystrokes/oowriter/bug_382415.py b/test/keystrokes/oowriter/bug_382415.py
index c46b7ad..21da55f 100644
--- a/test/keystrokes/oowriter/bug_382415.py
+++ b/test/keystrokes/oowriter/bug_382415.py
@@ -42,11 +42,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "Down arrow to move to the Mon table column header",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Mon Paragraph") + "'",
      "     VISIBLE:  'Mon Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Mon'",
      "SPEECH OUTPUT: 'Cell B1'"]))
 
diff --git a/test/keystrokes/oowriter/bug_382418.py b/test/keystrokes/oowriter/bug_382418.py
index 14752b3..71ee30b 100644
--- a/test/keystrokes/oowriter/bug_382418.py
+++ b/test/keystrokes/oowriter/bug_382418.py
@@ -79,11 +79,11 @@ sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "Type a down arrow to enter the table",
 
-    ["BRAILLE LINE:  'table with 2 rows and 2 columns.'",
-     "     VISIBLE:  'table with 2 rows and 2 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 2 rows 2 columns'",
+     "     VISIBLE:  'table with 2 rows 2 columns', cursor=0",
      "BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
      "     VISIBLE:  'Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 2 rows and 2 columns.'",
+     "SPEECH OUTPUT: 'table with 2 rows 2 columns'",
      "SPEECH OUTPUT: 'blank'",
      "SPEECH OUTPUT: 'Cell A1'"]))
 
diff --git a/test/keystrokes/oowriter/bug_382880.py b/test/keystrokes/oowriter/bug_382880.py
index d547126..c572aea 100644
--- a/test/keystrokes/oowriter/bug_382880.py
+++ b/test/keystrokes/oowriter/bug_382880.py
@@ -42,11 +42,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "Type a down arrow to move to the Mon table column header",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Mon Paragraph") + "'",
      "     VISIBLE:  'Mon Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Mon'",
      "SPEECH OUTPUT: 'Cell B1'"]))
 
diff --git a/test/keystrokes/oowriter/bug_382888.py b/test/keystrokes/oowriter/bug_382888.py
index 21dccc8..9caf924 100644
--- a/test/keystrokes/oowriter/bug_382888.py
+++ b/test/keystrokes/oowriter/bug_382888.py
@@ -42,11 +42,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "Type a down arrow to move to the Mon table column header",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Mon Paragraph") + "'",
      "     VISIBLE:  'Mon Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Mon'",
      "SPEECH OUTPUT: 'Cell B1'"]))
 
diff --git a/test/keystrokes/oowriter/table_cells.py b/test/keystrokes/oowriter/table_cells.py
index 2c492c8..9fd15f9 100644
--- a/test/keystrokes/oowriter/table_cells.py
+++ b/test/keystrokes/oowriter/table_cells.py
@@ -40,11 +40,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "1. Down",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Mon Paragraph") + "'",
      "     VISIBLE:  'Mon Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Mon'",
      "SPEECH OUTPUT: 'Cell B1'"]))
 
diff --git a/test/keystrokes/oowriter/table_cells_structural_navigation1.py b/test/keystrokes/oowriter/table_cells_structural_navigation1.py
index 330d4d0..0ba08c0 100644
--- a/test/keystrokes/oowriter/table_cells_structural_navigation1.py
+++ b/test/keystrokes/oowriter/table_cells_structural_navigation1.py
@@ -40,11 +40,11 @@ sequence.append(KeyComboAction("Down"))
 sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
 sequence.append(utils.AssertPresentationAction(
     "1. Down",
-    ["BRAILLE LINE:  'table with 7 rows and 7 columns.'",
-     "     VISIBLE:  'table with 7 rows and 7 columns.', cursor=0",
+    ["BRAILLE LINE:  'table with 7 rows 7 columns'",
+     "     VISIBLE:  'table with 7 rows 7 columns', cursor=0",
      "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample(.odt|)", "Calendar-1 Table Mon Paragraph") + "'",
      "     VISIBLE:  'Mon Paragraph', cursor=1",
-     "SPEECH OUTPUT: 'table with 7 rows and 7 columns.'",
+     "SPEECH OUTPUT: 'table with 7 rows 7 columns'",
      "SPEECH OUTPUT: 'Mon'",
      "SPEECH OUTPUT: 'Cell B1'"]))
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]