[Pkg-mozext-commits] [adblock-plus] 410/464: Crop Chrome descriptions

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 4d8a3eb191cd5249b86648788730da1397e234d9
Author: Felix Dahlke <felix at adblockplus.org>
Date:   Wed Dec 18 01:35:21 2013 +0100

    Crop Chrome descriptions
    
    Review: http://codereview.adblockplus.org/5163766501081088/
---
 localeTools.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/localeTools.py b/localeTools.py
index 196ab75..7938159 100644
--- a/localeTools.py
+++ b/localeTools.py
@@ -268,6 +268,11 @@ def preprocessChromeLocale(path, metadata, isMaster):
 
   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 @@ def postprocessChromeLocale(path, data):
     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()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list