Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: localeTools.py

Issue 5163766501081088: Crop Chrome descriptions (Closed)
Patch Set: Created Dec. 17, 2013, 11:52 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: localeTools.py
===================================================================
--- a/localeTools.py
+++ b/localeTools.py
@@ -268,6 +268,11 @@
return json.dumps(data, ensure_ascii=False, sort_keys=True, indent=2)
+def truncate(text, length_limit):
+ if len(text) <= length_limit:
+ return text
+ return text[:length_limit - 1].rstrip() + u"\u2026"
+
def postprocessChromeLocale(path, data):
parsed = json.loads(data)
if isinstance(parsed, list):
@@ -278,6 +283,11 @@
if "description" in value:
del value["description"]
+ # Crop Chrome description, we need to enforce the length limit
+ if "description_chrome" in parsed:
+ description_chrome = parsed["description_chrome"]
+ description_chrome["message"] = truncate(description_chrome["message"], 132)
+
file = codecs.open(path, 'wb', encoding='utf-8')
json.dump(parsed, file, ensure_ascii=False, sort_keys=True, indent=2, separators=(',', ': '))
file.close()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld