From 30114bd5aada3767f65477613ccfd918989a0c0e Mon Sep 17 00:00:00 2001 From: Wolfgang Lutz Date: Tue, 20 May 2025 10:04:31 +0200 Subject: [PATCH] implement escaping of %% to \% --- .../StringCatalog+Conversion.swift | 1 + .../Resources/SimpleTest/Input.xcstrings | 20 ++++++++++++++++++- .../Resources/SimpleTest/Output.de.xml | 1 + .../Resources/SimpleTest/Output.en.xml | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Sources/StringCatalogConverterLibrary/StringCatalog+Conversion.swift b/Sources/StringCatalogConverterLibrary/StringCatalog+Conversion.swift index 0741577..6d1d765 100644 --- a/Sources/StringCatalogConverterLibrary/StringCatalog+Conversion.swift +++ b/Sources/StringCatalogConverterLibrary/StringCatalog+Conversion.swift @@ -15,6 +15,7 @@ extension StringCatalog { .replacingOccurrences(of: "'", with: "\\'") .replacingOccurrences(of: "%@", with: "%1$s") .replacingOccurrences(of: "%d", with: "%2$d") + .replacingOccurrences(of: "%%", with: "\\%") // https://stackoverflow.com/a/74864023 } public func converted( diff --git a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Input.xcstrings b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Input.xcstrings index 225ee2d..d8a4e5a 100644 --- a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Input.xcstrings +++ b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Input.xcstrings @@ -52,6 +52,24 @@ } } }, + "concentrationPercent" : { + "comment" : "Label that represents the concentration of a solution in percent", + "extractionState" : "manual", + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "Konzentration in %%" + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "concentration in %%" + } + } + } + }, "counter.button" : { "extractionState" : "manual", "localizations" : { @@ -466,4 +484,4 @@ } }, "version" : "1.0" -} +} \ No newline at end of file diff --git a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.de.xml b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.de.xml index d5a678e..4f4cf2c 100644 --- a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.de.xml +++ b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.de.xml @@ -2,6 +2,7 @@ Child Tap Es sind keine Elemente anzuzeigen Element %1$s + Konzentration in \% Tap Anzahl der Child Taps: %2$d Number42 Website diff --git a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.en.xml b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.en.xml index 314eba4..aee3ae0 100644 --- a/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.en.xml +++ b/Tests/StringCatalogConverterLibraryTests/Resources/SimpleTest/Output.en.xml @@ -2,6 +2,7 @@ Child Tap There are no items to show Item %1$s + concentration in \% Tap Number of Child Taps: %2$d Number42 Website