From 12742d9df21d0c4d4be6451993c040fb008afb5f Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 6 Dec 2013 00:39:57 +0100 Subject: [PATCH 1/3] Add script to fix problematic linebreak/whitespace combinations in strings.xml --- tools/fix_all_strings.sh | 11 ++++++ tools/fix_strings.py | 76 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 tools/fix_all_strings.sh create mode 100755 tools/fix_strings.py diff --git a/tools/fix_all_strings.sh b/tools/fix_all_strings.sh new file mode 100755 index 000000000..47d837735 --- /dev/null +++ b/tools/fix_all_strings.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +SCRIPT=$(readlink -f $0) +SCRIPTPATH=`dirname $SCRIPT` +PROJECTROOT=`dirname $SCRIPTPATH` + +cd $PROJECTROOT + +find res/values* -name "strings.xml" -type f ! -wholename "res/values-fr-rCA/strings.xml" -exec ./tools/fix_strings.py {} \; + +cd - diff --git a/tools/fix_strings.py b/tools/fix_strings.py new file mode 100755 index 000000000..ff2ce52a2 --- /dev/null +++ b/tools/fix_strings.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# Rewrite a strings file to get rid of line break/whitespace combinations that get stripped when building with Gradle. +# +# Example: +# +# Account \"%s\" shrunk from +# %s +# to +# %s +# +# +# will be rendered as +# +# Account "account" shrunk from10MB to1MB +# +# when built with Gradle, but displays fine when built with Ant. +# +# +# Written for use with K-9 Mail (https://github.com/k9mail/k-9) +# Licensed under the WTFPL (http://www.wtfpl.net/about/) + +import sys +import re +from lxml import etree + + +def fix_text(element): + if element.text is not None: + element.text = re.sub(r'^\n\s*([^\s])', "\\1", element.text) + element.text = re.sub(r'\n\s*$', " ", element.text) + + +def fix_tail(element, is_last): + if element.tail is not None: + if is_last: + replacement = "" + else: + replacement = " " + element.tail = re.sub(r'^\n\s*([^\s])', " \\1", element.tail) + element.tail = re.sub(r'\n\s*$', replacement, element.tail) + + +def cleanup_string_elements(elements): + for element in elements: + if element.tag is None: + continue + + tag = element.tag + children = element.getchildren() + + if tag in ["string", "item"]: + if len(children) > 0: + fix_text(element) + + for child in children: + if isinstance(child.tag, basestring): + fix_text(child) + fix_tail(child, child == children[-1]) + + elif tag == "plurals": + cleanup_string_elements(children) + + +if len(sys.argv) < 2: + print "Usage: fix_strings.py " + print "Example: fix_strings.py res/values/strings.xml" + exit(1) + +strings_file = sys.argv[1] + +parser = etree.XMLParser(strip_cdata=False) +strings = etree.parse(strings_file, parser=parser) + +cleanup_string_elements(strings.getroot().getchildren()) + +strings.write(strings_file, xml_declaration=True, encoding="UTF-8", pretty_print=True) From 957dc2af5b62817b33294ac8e38a6b08a0a1ad28 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 6 Dec 2013 01:30:00 +0100 Subject: [PATCH 2/3] Replace no-break spaces with regular space characters --- res/values-fi/strings.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 51f405f39..562711649 100755 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -190,7 +190,7 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen Yritetään ladata uudelleen lisää viestejä Lataa -      %d lisää + %d lisää Gt Mt @@ -199,9 +199,9 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen Tilin \"%s\" vanha koko -     %s -     on nyt -     %s + %s + on nyt + %s Tiivistetään tiliä \"%s\" @@ -788,12 +788,12 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen -       1 - Näytä vain 1. luokan kansiot\u000A -       2 - Näytä 1. ja 2. luokan kansiot\u000A -       3 - Näytä kaikki paitsi 2. luokan kansiot\u000A -       4 - Näytä kaikki kansiot\u000A -       Q - Palaa tileihin\u000A -       S - Muokkaa tilin asetuksia + 1 - Näytä vain 1. luokan kansiot\u000A + 2 - Näytä 1. ja 2. luokan kansiot\u000A + 3 - Näytä kaikki paitsi 2. luokan kansiot\u000A + 4 - Näytä kaikki kansiot\u000A + Q - Palaa tileihin\u000A + S - Muokkaa tilin asetuksia kansionimi sisältää From 956972b8d003ad6829a89e26dd3c4b07e5479bb6 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 6 Dec 2013 02:59:58 +0100 Subject: [PATCH 3/3] Remove problematic linebreaks from strings files --- res/values-ca/strings.xml | 7 +------ res/values-cs/strings.xml | 7 +------ res/values-da/strings.xml | 7 +------ res/values-de/strings.xml | 11 ++--------- res/values-el/strings.xml | 3 +-- res/values-es/strings.xml | 7 +------ res/values-fi/strings.xml | 10 ++-------- res/values-fr/strings.xml | 7 +------ res/values-gl/strings.xml | 7 +------ res/values-hu/strings.xml | 7 +------ res/values-it/strings.xml | 10 ++-------- res/values-iw/strings.xml | 6 +----- res/values-ja/strings.xml | 7 +------ res/values-ko/strings.xml | 7 +------ res/values-nl/strings.xml | 7 +------ res/values-pl/strings.xml | 3 +-- res/values-pt-rBR/strings.xml | 4 +--- res/values-sk/strings.xml | 7 +------ res/values-sv/strings.xml | 7 +------ res/values-tr/strings.xml | 10 ++-------- res/values-uk/strings.xml | 10 ++-------- res/values/strings.xml | 13 ++++--------- 22 files changed, 30 insertions(+), 134 deletions(-) diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 900010d25..4e8371f2d 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -196,12 +196,7 @@ Si us plau, envia\'ns els errors, contribueix a millorar-lo a KB B - - Compte \"%s\" comprimida des de - %s - a - %s - + Compte \"%s\" comprimida des de %s a %s S\'està compactant el compte \"%s\" S\'està netejant el compte \"%s\" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index c80845ef1..7a8adae43 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -200,12 +200,7 @@ Posílejte prosím chybová hlášení, přispívejte novými funkcemi a ptejte KiB B - - Účet \"%s\" byl stlačen z - %s - na - %s - + Účet \"%s\" byl stlačen z %s na %s Stlačuji účet \"%s\" Čistím účet \"%s\" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 99d464f29..057ad7e3c 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -196,12 +196,7 @@ Vær venlig at sende fejlrapporter, anmodning om nye funktioner, og spørgsmål KB B - - Konto \"%s\" nedbragt fra - %s - til - %s - + Konto \"%s\" nedbragt fra %s til %s Komprimerer konto \"%s\" Renser konto \"%s\" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 675968574..ebfae9f52 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -187,21 +187,14 @@ Um Fehler zu melden, neue Funktionen vorzuschlagen oder Fragen zu stellen, besuc Ladevorgang erneut starten - Bis zu - %d weitere abrufen + Bis zu %d weitere abrufen GB MB KB B - - Konto \'%s\' von - %s - auf - %s - komprimiert - + Konto \'%s\' von %s auf %s komprimiert Konto \'%s\' wird komprimiert Konto \'%s\' wird bereinigt diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 8a6fdbd39..8ce94f0cd 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -195,8 +195,7 @@ Kb b - Ο λογαριασμός \'%s\' συμπυκνώθηκε από - %s σε %s + Ο λογαριασμός \'%s\' συμπυκνώθηκε από %s σε %s Συμπύκνωση λογαριασμού \'%s\' Καθαρισμός λογαριασμού \'%s\' diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index fcf883598..beef8cc88 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -195,12 +195,7 @@ Por favor, envía los errores detectados, contribuye con nuevas funcionalidades KB B - - Cuenta \"%s\" reducida desde - %s - a - %s - + Cuenta \"%s\" reducida desde %s a %s Compactando cuenta \"%s\" Limpiando cuenta \"%s\" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 562711649..85657f0b3 100755 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -189,20 +189,14 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen Yritetään ladata uudelleen lisää viestejä - Lataa - %d lisää + Lataa %d lisää Gt Mt kt t - - Tilin \"%s\" vanha koko - %s - on nyt - %s - + Tilin \"%s\" vanha koko %s on nyt %s Tiivistetään tiliä \"%s\" Tyhjennetään tiliä \"%s\" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 82c319b0b..c10d7d021 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -221,12 +221,7 @@ de plus ko oct. - - Espace sur «\u00A0%s\u00A0» passé de - %s - à - %s - + Espace sur «\u00A0%s\u00A0» passé de %s à %s Compactage du compte «\u00A0%s\u00A0» Effacement du compte «\u00A0%s\u00A0» diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index 6877fdb06..a891ec599 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -195,12 +195,7 @@ Por favor, envía os erros detectados, contribúe con novas funcionalidas e preg KB B - - Conta \"%s\" reducida dende - %s - a - %s - + Conta \"%s\" reducida dende %s a %s Compactando conta \"%s\" Limpando conta \"%s\" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 6fc71d24e..98931e670 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -196,12 +196,7 @@ Hibajelentéseivel hozzájárul az újabb verziók tökéletesítéséhez, kérd KB B - - \"%s\" fiók tömörítése - %s - helyett - %s - + \"%s\" fiók tömörítése %s helyett %s Fiók tömörítése \"%s\" Fiók takarítása \"%s\" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index d45261e94..476926fed 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -188,20 +188,14 @@ Invia le tue segnalazioni, suggerisci nuove funzionalità e chiedi informazioni Riprova a caricare altri messaggi - Scarica altri - %d messaggi + Scarica altri %d messaggi GB MB KB B - - Account \"%s\" ridimensionato da - %s - a - %s - + Account \"%s\" ridimensionato da %s a %s Compattazione account \"%s\" Rimozione account \"%s\" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index c192b2c7c..14d76d586 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -197,11 +197,7 @@ B - חשבון \"%s\" נדחס ל - %s - to - %s - + חשבון \"%s\" נדחס ל %s to %s דחיסת חשבון מנקה חשבון \"%s\" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index a524e5626..3a703074a 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -195,12 +195,7 @@ K-9 は大多数のメールクライアントと同様に、ほとんどのフ KB B - - アカウント \"%s\" 現在 - %s - から - %s へ - + アカウント \"%s\" 現在 %s から %s アカウント \"%s\" を最適化しています アカウント \"%s\" をクリアしています diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index a853e6b2a..a8712d3a8 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -194,12 +194,7 @@ K-9 메일은 대부분의 무료 hotmail 계정을 지원하지 않으며, 다 KB B - - \"%s\" 계정이 차지하는 용량이 - %s - 에서 - %s 로 줄었습니다 - + \"%s\" 계정이 차지하는 용량이 %s 에서 %s 로 줄었습니다 계정 최적화 \"%s\" 계정 비우기 \"%s\" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index b5a416905..c02e6adaf 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -195,12 +195,7 @@ Graag foutrapporten, bijdrage nieuwe functies en vragen stellen op KB B - - Account \"%s\" shrunk van - %s - naar - %s - + Account \"%s\" shrunk van %s naar %s Account \"%s\" comprimeren Account \"%s\" wissen diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 389ec6dc9..a1cda7f6e 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -206,8 +206,7 @@ Wszelkie zgłoszenia usterek, zapytania oraz nowe pomysły prosimy przesyłać z KB B - - Objętość konta \"%s\" zmniejszyła się z %s do %s + Objętość konta \"%s\" zmniejszyła się z %s do %s Kompaktuję konto \"%s\" Czyszczę konto \"%s\" diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml index 2344b2431..3b29abd57 100644 --- a/res/values-pt-rBR/strings.xml +++ b/res/values-pt-rBR/strings.xml @@ -195,9 +195,7 @@ Por favor, nos envie relatórios de bugs, contribua para novas melhorias e faça KB B - - Conta \"%s\" reduziu-se de %s para %s - + Conta \"%s\" reduziu-se de %s para %s Compactando conta \"%s\" Limpando conta \"%s\" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 948793647..846c47b8c 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -196,12 +196,7 @@ Prosím nahlasujte prípadné chyby, prispievajte novými funkciami a pýtajte s KB B - - Účet \"%s\" bol zmenšený z - %s - na - %s - + Účet \"%s\" bol zmenšený z %s na %s Zmenšujem účet \"%s\" Čistím účet \"%s\" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 586cf40b6..e5227bb8d 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -196,12 +196,7 @@ Vänligen skicka felrapporter, hjälp till med nya funktioner och ställ frågor KB B - - Kontot \"%s\" har krympt från - %s - till - %s - + Kontot \"%s\" har krympt från %s till %s Komprimerar konto \"%s\" Rensar konto \"%s\" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index b01e8b92c..1a8d8431c 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -188,20 +188,14 @@ Lütfen hata raporlarınızı, istediğiniz yeni özellikleri ve sorularınızı Birden fazla mesaj yüklemeyi deniyor - Boyuta kadar yükle - %d daha fazla + Boyuta kadar yükle %d daha fazla GB MB KB B - - \"%s\" hesabı - %s - den - %s\'e küçüldü - + \"%s\" hesabı %s den %s\'e küçüldü Hesap sıkıştırma \"%s\" Hesap temizleme \"%s\" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 006700379..00a92cc3d 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -188,20 +188,14 @@ K-9 Mail це поштовий клієнт з відкритим вихідни Спробуйте ще раз завантажити повідомлення - Завантажити ще - %d + Завантажити ще %d ГБ МБ кБ Б - - Розмір \"%s\" зменшився від - %s - до - %s - + Розмір \"%s\" зменшився від %s до %s Стискання скриньки \"%s\" Очищення скриньки \"%s\" diff --git a/res/values/strings.xml b/res/values/strings.xml index e1cafb5d4..a79f1f6bd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,4 +1,4 @@ - +