mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix unescaped quote in new translation and make translator escape quotes going forward
This commit is contained in:
parent
9c4b8ed860
commit
563294b36e
|
@ -112,7 +112,7 @@
|
||||||
<string name="preferences_front_light_summary">Améliore le balayage lors d\'une faible luminosité sur certains téléphone, mais peut causer un reflet. Ne fonctionne pas sur tous les téléphones.</string>
|
<string name="preferences_front_light_summary">Améliore le balayage lors d\'une faible luminosité sur certains téléphone, mais peut causer un reflet. Ne fonctionne pas sur tous les téléphones.</string>
|
||||||
<string name="preferences_front_light_title">Utiliser la lumière frontale</string>
|
<string name="preferences_front_light_title">Utiliser la lumière frontale</string>
|
||||||
<string name="preferences_general_title">Paramètres généraux</string>
|
<string name="preferences_general_title">Paramètres généraux</string>
|
||||||
<string name="preferences_history_summary">Stockez vos scans dans l'histoire</string>
|
<string name="preferences_history_summary">Stockez vos scans dans l\'histoire</string>
|
||||||
<string name="preferences_history_title">Ajouter à Histoire</string>
|
<string name="preferences_history_title">Ajouter à Histoire</string>
|
||||||
<string name="preferences_invert_scan_summary">Balayer des codes-barres blancs sur fond noir. Non disponible sur certains appareils.</string>
|
<string name="preferences_invert_scan_summary">Balayer des codes-barres blancs sur fond noir. Non disponible sur certains appareils.</string>
|
||||||
<string name="preferences_invert_scan_title">Balayage négatif</string>
|
<string name="preferences_invert_scan_title">Balayage négatif</string>
|
||||||
|
|
|
@ -118,7 +118,9 @@ public final class StringsResourceTranslator {
|
||||||
String parentName = translatedFile.getParent().getFileName().toString();
|
String parentName = translatedFile.getParent().getFileName().toString();
|
||||||
|
|
||||||
Matcher stringsFileNameMatcher = STRINGS_FILE_NAME_PATTERN.matcher(parentName);
|
Matcher stringsFileNameMatcher = STRINGS_FILE_NAME_PATTERN.matcher(parentName);
|
||||||
stringsFileNameMatcher.find();
|
if (!stringsFileNameMatcher.find()) {
|
||||||
|
throw new IllegalArgumentException("Invalid parent dir: " + parentName);
|
||||||
|
}
|
||||||
String language = stringsFileNameMatcher.group(1);
|
String language = stringsFileNameMatcher.group(1);
|
||||||
String massagedLanguage = LANGUAGE_CODE_MASSAGINGS.get(language);
|
String massagedLanguage = LANGUAGE_CODE_MASSAGINGS.get(language);
|
||||||
if (massagedLanguage != null) {
|
if (massagedLanguage != null) {
|
||||||
|
@ -151,6 +153,8 @@ public final class StringsResourceTranslator {
|
||||||
if (translatedString == null || forceRetranslation.contains(key)) {
|
if (translatedString == null || forceRetranslation.contains(key)) {
|
||||||
anyChange = true;
|
anyChange = true;
|
||||||
translatedString = translateString(value, language);
|
translatedString = translateString(value, language);
|
||||||
|
// Specially for string resources, escape ' with \
|
||||||
|
translatedString = translatedString.replaceAll("'", "\\\\'");
|
||||||
}
|
}
|
||||||
out.write(translatedString);
|
out.write(translatedString);
|
||||||
|
|
||||||
|
@ -193,10 +197,8 @@ public final class StringsResourceTranslator {
|
||||||
String translation = m.group(1);
|
String translation = m.group(1);
|
||||||
|
|
||||||
// This is a little crude; unescape some common escapes in the raw response
|
// This is a little crude; unescape some common escapes in the raw response
|
||||||
translation = translation.replaceAll(""", "\"");
|
translation = translation.replaceAll("&(amp;)?quot;", "\"");
|
||||||
translation = translation.replaceAll("'", "'");
|
translation = translation.replaceAll("&(amp;)?#39;", "'");
|
||||||
translation = translation.replaceAll("&quot;", "\"");
|
|
||||||
translation = translation.replaceAll("&#39;", "'");
|
|
||||||
|
|
||||||
System.out.println(" Got translation " + translation);
|
System.out.println(" Got translation " + translation);
|
||||||
return translation;
|
return translation;
|
||||||
|
|
Loading…
Reference in a new issue