[orca] Fix for bgo#585792 - i18n strings should use parameterized forms
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca] Fix for bgo#585792 - i18n strings should use parameterized forms
- Date: Sun, 14 Jun 2009 21:44:41 -0400 (EDT)
commit b31ecb060be95c74e02c2f9f225afa0b275fb5c3
Author: Willie Walker <william walker sun com>
Date: Sun Jun 14 21:42:53 2009 -0400
Fix for bgo#585792 - i18n strings should use parameterized forms
src/orca/default.py | 18 +++++----
src/orca/scripts/apps/acroread.py | 11 +++---
src/orca/scripts/apps/soffice/script.py | 13 ++++---
src/orca/speech_generator.py | 59 ++++++++++++++++--------------
src/orca/structural_navigation.py | 12 ++++---
5 files changed, 61 insertions(+), 52 deletions(-)
---
diff --git a/src/orca/default.py b/src/orca/default.py
index 8b4ded0..938db0b 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -4372,10 +4372,11 @@ class Script(script.Script):
# application, so we leave things in plural form
# here.
#
- line = ngettext("%s %s pixel",
- "%s %s pixels",
- int(attribute)) % \
- (localizedKey, localizedValue)
+ line = ngettext("%(key)s %(value)s pixel",
+ "%(key)s %(value)s pixels",
+ int(attribute)) \
+ % {"key" : localizedKey,
+ "value": localizedValue}
elif key in ["indent", "size"]:
# In Gecko, we seem to get these values as a number
# immediately followed by "px". But we'll hedge our
@@ -4383,10 +4384,11 @@ class Script(script.Script):
#
value = attribute.split("px")
if len(value) > 1:
- line = ngettext("%s %s pixel",
- "%s %s pixels",
- float(value[0])) % \
- (localizedKey, value[0])
+ line = ngettext("%(key)s %(value)s pixel",
+ "%(key)s %(value)s pixels",
+ float(value[0])) \
+ % {"key" : localizedKey,
+ "value" : value[0]}
elif key == "family-name":
# In Gecko, we get a huge list and we just want the
# first one. See:
diff --git a/src/orca/scripts/apps/acroread.py b/src/orca/scripts/apps/acroread.py
index b043f13..175a75f 100644
--- a/src/orca/scripts/apps/acroread.py
+++ b/src/orca/scripts/apps/acroread.py
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2007-2008 Sun Microsystems Inc. and Joanmarie Diggs
+# Copyright 2007-2009 Sun Microsystems Inc. and Joanmarie Diggs
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -22,7 +22,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2007-2008 Sun Microsystems Inc. Joanmarie Diggs"
+__copyright__ = "Copyright (c) 2007-2009 Sun Microsystems Inc. Joanmarie Diggs"
__license__ = "LGPL"
import pyatspi
@@ -273,8 +273,8 @@ class Script(default.Script):
if not oldFocusIsTable and newFocusIsTable:
# We've entered a table. Announce the dimensions.
#
- line = _("table with %d rows and %d columns.") % \
- (newFocusRows, newFocusColumns)
+ line = _("table with %(rows)d rows and %(columns)d columns.") \
+ % {"rows" : newFocusRows, "columns" : newFocusColumns}
speech.speak(line)
elif oldFocusIsTable and not newFocusIsTable:
@@ -298,7 +298,8 @@ class Script(default.Script):
# Translators: this represents the row and column we're
# on in a table.
#
- line = _("row %d, column %d") % (newRow, newCol)
+ line = _("row %(row)d, column %(column)d") \
+ % {"row": newRow, "column": newCol}
speech.speak(line)
elif newCol != oldCol:
# Translators: this represents the column we're
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 4bf7d2b..9ed279d 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -34,7 +34,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import gtk
@@ -879,8 +879,9 @@ class Script(default.Script):
if newTable:
# We've entered a table. Announce the dimensions.
#
- line = _("table with %d rows and %d columns.") % \
- (newTable.nRows, newTable.nColumns)
+ line = _("table with %(rows)d rows and %(columns)d columns.") \
+ % {"rows" : newTable.nRows,
+ "columns" : newTable.nColumns}
speech.speak(line)
if not newTable:
@@ -1876,7 +1877,7 @@ class Script(default.Script):
# event.source lacks STATE_FOCUSED. This causes the default
# script to ignore the event. See bug #523416. [[[TODO - JD:
# If the OOo guys fix this on their end, this hack should be
- # removed. The OOo issue can be found here:
+ # removed. The OOo issue can be found here:
# http://www.openoffice.org/issues/show_bug.cgi?id=93083]]]
#
rolesList = [pyatspi.ROLE_LIST,
@@ -2405,7 +2406,7 @@ class Script(default.Script):
# dialog, and loses focus requiring the user to know that it's
# there and needs Alt+F6ing into. But officially it's a normal
# window.
-
+
# There doesn't seem to be (an efficient) top-down equivalent
# of isDesiredFocusedItem(). But OOo documents have root panes;
# this thing does not.
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 4d6b65f..205a50e 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -555,12 +555,13 @@ class SpeechGenerator:
# and the second item the name of the file being linked
# to.
#
- result.append(_('%s link to %s') %\
- (link_uri_info[0], fileName[-1]))
+ result.append(_("%(uri)s link to %(file)s") \
+ % {"uri" : link_uri_info[0],
+ "file" : fileName[-1]})
else:
# Translators: this is the protocol of a link eg. http, mailto.
#
- linkOutput = _('%s link') %link_uri_info[0]
+ linkOutput = _("%s link") % link_uri_info[0]
text = self._script.getDisplayedText(obj)
if not text:
# If there's no text for the link, expose part of the
@@ -593,13 +594,13 @@ class SpeechGenerator:
# Translators: this is an indication that a given
# link points to an object that is on the same page.
#
- result.append(_('same page'))
+ result.append(_("same page"))
else:
# Translators: this is an indication that a given
# link points to an object that is at the same site
# (but not on the same page as the link).
#
- result.append(_('same site'))
+ result.append(_("same site"))
else:
# check for different machine name on same site
#
@@ -612,13 +613,13 @@ class SpeechGenerator:
# link points to an object that is at the same site
# (but not on the same page) as the link.
#
- result.append(_('same site'))
+ result.append(_("same site"))
else:
# Translators: this is an indication that a given
# link points to an object that is at a different
# site than that of the link.
#
- result.append(_('different site'))
+ result.append(_("different site"))
return result
def _generateFileSize(self, obj, **args):
@@ -645,15 +646,15 @@ class SpeechGenerator:
if size < 10000:
# Translators: This is the size of a file in bytes
#
- result.append(ngettext('%d byte', '%d bytes', size) % size)
+ result.append(ngettext("%d byte", "%d bytes", size) % size)
elif size < 1000000:
# Translators: This is the size of a file in kilobytes
#
- result.append(_('%.2f kilobytes') % (float(size) * .001))
+ result.append(_("%.2f kilobytes") % (float(size) * .001))
elif size >= 1000000:
# Translators: This is the size of a file in megabytes
#
- result.append(_('%.2f megabytes') % (float(size) * .000001))
+ result.append(_("%.2f megabytes") % (float(size) * .000001))
return result
#####################################################################
@@ -1176,10 +1177,14 @@ class SpeechGenerator:
row = table.getRowAtIndex(index)
# Translators: this is in references to a column in a
# table.
- result.append(_("column %d of %d") % ((col + 1), table.nColumns))
+ result.append(_("column %(index)d of %(total)d") \
+ % {"index" : (col + 1),
+ "total" : table.nColumns})
# Translators: this is in reference to a row in a table.
#
- result.append(_("row %d of %d") % ((row + 1), table.nRows))
+ result.append(_("row %(index)d of %(total)d") \
+ % {"index" : (row + 1),
+ "total" : table.nRows})
return result
def _generateEndOfTableIndicator(self, obj, **args):
@@ -1730,16 +1735,19 @@ class SpeechGenerator:
# and the count of the total number of icons within an icon panel.
# An example of an icon panel is the Nautilus folder view.
#
- countString = ngettext("%d of %d item selected",
- "%d of %d items selected",
- childCount) % \
- (totalSelectedItems, childCount)
+ countString = ngettext("%(index)d of %(total)d item selected",
+ "%(index)d of %(total)d items selected",
+ childCount) \
+ % {"index" : totalSelectedItems,
+ "total" : childCount}
result.append(countString)
# Translators: this is a indication of the focused icon and the
# count of the total number of icons within an icon panel. An
# example of an icon panel is the Nautilus folder view.
#
- itemString = _("on item %d of %d") % (currentItem, childCount)
+ itemString = _("on item %(index)d of %(total)d") \
+ % {"index" : currentItem,
+ "total" : childCount}
result.append(itemString)
return result
@@ -1893,7 +1901,9 @@ class SpeechGenerator:
if position >= 0:
# Translators: this is an item in a list.
#
- result.append(_("item %d of %d") % (position, total))
+ result.append(_("item %(index)d of %(total)d") \
+ % {"index" : position,
+ "total" : total})
return result
@@ -1969,7 +1979,9 @@ class SpeechGenerator:
if position >= 0:
# Translators: this is an item in a list.
#
- result.append(_("item %d of %d") % (position, total))
+ result.append(_("item %(index)d of %(total)d") \
+ % {"index" : position,
+ "total" : total})
return result
@@ -2015,9 +2027,6 @@ class SpeechGenerator:
specifications) that represent the default button of the window
containing the object.
"""
- # TODO/Question - JD to WDW: Do we want to add this to the
- # formatting strings? For now, I've not done that.
- #
return self._generateDefaultButton(obj, **args)
def _generateStatusBar(self, obj, **args):
@@ -2041,9 +2050,6 @@ class SpeechGenerator:
specifications) that represent the status bar of the window
containing the object.
"""
- # TODO/Question - JD to WDW: Do we want to add this to the
- # formatting strings? For now, I've not done that.
- #
return self._generateStatusBar(obj, **args)
def generateTitle(self, obj, **args):
@@ -2052,9 +2058,6 @@ class SpeechGenerator:
containing the object, along with information associated with
any unfocused dialog boxes.
"""
- # TODO/Question - JD to WDW: Do we want to add this to the
- # formatting strings? For now, I've not done that.
- #
result = []
frame, dialog = self._script.findFrameAndDialog(obj)
if frame:
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index dfa76bd..2001db2 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -24,7 +24,7 @@ script providing access to document content."""
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
@@ -1483,8 +1483,9 @@ class StructuralNavigation:
# 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 and %d columns") % \
- (rowspan, colspan)
+ spanString = _("Cell spans %(rows)d rows and %(columns)d columns") \
+ % {"rows" : rowspan,
+ "columns" : colspan}
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
@@ -3307,7 +3308,8 @@ class StructuralNavigation:
# Translators: this represents the (row, col) position of
# a cell in a table.
#
- speech.speak(_("Row %d, column %d.") % (row + 1, col + 1))
+ speech.speak(_("Row %(row)d, column %(column)d.") \
+ % {"row" : row + 1, "column" : col + 1})
spanString = self._getCellSpanInfo(cell)
if spanString and settings.speakCellSpan:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]