| 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() |