Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Unified Diff: grit/clique.py

Issue 9958067: Fixing a bug in GRIT where messages with substitutions would (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grit/clique_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/clique.py
diff --git a/grit/clique.py b/grit/clique.py
index da023288702732d406000b320ad8563a5996b996..64bbdb56ebcd10e08680d0c4979f81b5fe602f74 100644
--- a/grit/clique.py
+++ b/grit/clique.py
@@ -11,6 +11,7 @@ import types
from grit import constants
from grit import exception
+from grit import lazy_re
from grit import pseudo
from grit import pseudo_rtl
from grit import tclib
@@ -281,9 +282,15 @@ class MessageClique(object):
# special language constants.CONSTANT_LANGUAGE.
CONSTANT_TRANSLATION = tclib.Translation(text='TTTTTT')
+ # A pattern to match messages that are empty or whitespace only.
+ WHITESPACE_MESSAGE = lazy_re.compile(u'^( |\t|\n|\r|\xa0)*$')
+
def __init__(self, uber_clique, message, translateable=True, custom_type=None):
'''Create a new clique initialized with just a message.
+ Note that messages with a body comprised only of whitespace will implicitly
+ be marked non-translatable.
+
Args:
uber_clique: Our uber-clique (collection of cliques)
message: tclib.Message()
@@ -294,6 +301,12 @@ class MessageClique(object):
self.uber_clique = uber_clique
# If not translateable, we only store the original message.
self.translateable = translateable
+
+ # We implicitly mark messages that have a whitespace-only body as
+ # non-translateable.
+ if MessageClique.WHITESPACE_MESSAGE.match(message.GetRealContent()):
+ self.translateable = False
+
# A mapping of language identifiers to tclib.BaseMessage and its
# subclasses (i.e. tclib.Message and tclib.Translation).
self.clique = { MessageClique.source_language : message }
« no previous file with comments | « no previous file | grit/clique_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698