From 403ee63615976181dd1efe08a260e1f8d391d5a0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 17 Dec 2020 12:41:23 +0100 Subject: [PATCH] project: generate more stable locale IDs Signed-off-by: Jason A. Donenfeld --- WireGuard.xcodeproj/project.pbxproj | 76 ++++++++++++++--------------- sync-translations.sh | 8 ++- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/WireGuard.xcodeproj/project.pbxproj b/WireGuard.xcodeproj/project.pbxproj index 7b2f11a..1b282d2 100644 --- a/WireGuard.xcodeproj/project.pbxproj +++ b/WireGuard.xcodeproj/project.pbxproj @@ -399,24 +399,24 @@ 6FDEF801218646B900D8FBF6 /* ZipArchive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZipArchive.swift; sourceTree = ""; }; 6FDEF805218725D200D8FBF6 /* SettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsTableViewController.swift; sourceTree = ""; }; 6FE1765521C90BBE002690EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Sources/WireGuardApp/Base.lproj/Localizable.strings; sourceTree = ""; }; - B42B98244F62B9607F9B45CA /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh-Hant; path = Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings; sourceTree = ""; }; - 30DA2ED43960DE77912BD89D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh-Hans; path = Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings; sourceTree = ""; }; - 2A4344354DDBADE335B5FD2D /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = Sources/WireGuardApp/id.lproj/Localizable.strings; sourceTree = ""; }; - B829B6E3BE26C748A53A64EE /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = Sources/WireGuardApp/it.lproj/Localizable.strings; sourceTree = ""; }; - 5042B6E2E62F7B7537D0EE57 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Sources/WireGuardApp/de.lproj/Localizable.strings; sourceTree = ""; }; - 7872E185E096988E9990CC29 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Sources/WireGuardApp/fr.lproj/Localizable.strings; sourceTree = ""; }; - 36AFA3DAC2091DD81699B978 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = Sources/WireGuardApp/fi.lproj/Localizable.strings; sourceTree = ""; }; - 9A06FF3EF8255B77287F0195 /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = Sources/WireGuardApp/fa.lproj/Localizable.strings; sourceTree = ""; }; - A7C540D3D2E36084F9AB8A0E /* sl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sl; path = Sources/WireGuardApp/sl.lproj/Localizable.strings; sourceTree = ""; }; - 241E007502395B1D0666EE3B /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = Sources/WireGuardApp/pl.lproj/Localizable.strings; sourceTree = ""; }; - 95493F9EF05B71D3B1A5131C /* pa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pa; path = Sources/WireGuardApp/pa.lproj/Localizable.strings; sourceTree = ""; }; - C56DE3E0E402E403CA43BF97 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = Sources/WireGuardApp/ko.lproj/Localizable.strings; sourceTree = ""; }; - 5BE8673E6D8166A17C07E2BC /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = Sources/WireGuardApp/ca.lproj/Localizable.strings; sourceTree = ""; }; - 63ADFB23B4BDD4ECA5B8E84B /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = Sources/WireGuardApp/ru.lproj/Localizable.strings; sourceTree = ""; }; - 47F144079FFBAE33E6A7320E /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = Sources/WireGuardApp/ro.lproj/Localizable.strings; sourceTree = ""; }; - C383A8BE821704F21E30AC2A /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = Sources/WireGuardApp/tr.lproj/Localizable.strings; sourceTree = ""; }; - BD397C79F39F133A747A55BB /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = Sources/WireGuardApp/ja.lproj/Localizable.strings; sourceTree = ""; }; - 88C333FB84302A6942903F37 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Sources/WireGuardApp/es.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC6 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh-Hant; path = Sources/WireGuardApp/zh-Hant.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBA /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh-Hans; path = Sources/WireGuardApp/zh-Hans.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC5 /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = Sources/WireGuardApp/id.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBC /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = Sources/WireGuardApp/it.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC3 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Sources/WireGuardApp/de.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFB5 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Sources/WireGuardApp/fr.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBF /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = Sources/WireGuardApp/fi.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBE /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = Sources/WireGuardApp/fa.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC4 /* sl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sl; path = Sources/WireGuardApp/sl.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFB6 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = Sources/WireGuardApp/pl.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFB9 /* pa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pa; path = Sources/WireGuardApp/pa.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC1 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = Sources/WireGuardApp/ko.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFB8 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = Sources/WireGuardApp/ca.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC0 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = Sources/WireGuardApp/ru.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBD /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = Sources/WireGuardApp/ro.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFC2 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = Sources/WireGuardApp/tr.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFBB /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = Sources/WireGuardApp/ja.lproj/Localizable.strings; sourceTree = ""; }; + 6F70E20D221058DF008BDFB7 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Sources/WireGuardApp/es.lproj/Localizable.strings; sourceTree = ""; }; 6FE1765921C90E87002690EA /* LocalizationHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizationHelper.swift; sourceTree = ""; }; 6FE254FA219C10800028284D /* ZipImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZipImporter.swift; sourceTree = ""; }; 6FE254FE219C60290028284D /* ZipExporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZipExporter.swift; sourceTree = ""; }; @@ -1021,8 +1021,8 @@ knownRegions = ( Base, en, - zh-Hant, - zh-Hans, + "zh-Hant", + "zh-Hans", id, it, de, @@ -1501,24 +1501,24 @@ 6FE1765421C90BBE002690EA /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( - B42B98244F62B9607F9B45CA /* zh-Hant */, - 30DA2ED43960DE77912BD89D /* zh-Hans */, - 2A4344354DDBADE335B5FD2D /* id */, - B829B6E3BE26C748A53A64EE /* it */, - 5042B6E2E62F7B7537D0EE57 /* de */, - 7872E185E096988E9990CC29 /* fr */, - 36AFA3DAC2091DD81699B978 /* fi */, - 9A06FF3EF8255B77287F0195 /* fa */, - A7C540D3D2E36084F9AB8A0E /* sl */, - 241E007502395B1D0666EE3B /* pl */, - 95493F9EF05B71D3B1A5131C /* pa */, - C56DE3E0E402E403CA43BF97 /* ko */, - 5BE8673E6D8166A17C07E2BC /* ca */, - 63ADFB23B4BDD4ECA5B8E84B /* ru */, - 47F144079FFBAE33E6A7320E /* ro */, - C383A8BE821704F21E30AC2A /* tr */, - BD397C79F39F133A747A55BB /* ja */, - 88C333FB84302A6942903F37 /* es */, + 6F70E20D221058DF008BDFC6 /* zh-Hant */, + 6F70E20D221058DF008BDFBA /* zh-Hans */, + 6F70E20D221058DF008BDFC5 /* id */, + 6F70E20D221058DF008BDFBC /* it */, + 6F70E20D221058DF008BDFC3 /* de */, + 6F70E20D221058DF008BDFB5 /* fr */, + 6F70E20D221058DF008BDFBF /* fi */, + 6F70E20D221058DF008BDFBE /* fa */, + 6F70E20D221058DF008BDFC4 /* sl */, + 6F70E20D221058DF008BDFB6 /* pl */, + 6F70E20D221058DF008BDFB9 /* pa */, + 6F70E20D221058DF008BDFC1 /* ko */, + 6F70E20D221058DF008BDFB8 /* ca */, + 6F70E20D221058DF008BDFC0 /* ru */, + 6F70E20D221058DF008BDFBD /* ro */, + 6F70E20D221058DF008BDFC2 /* tr */, + 6F70E20D221058DF008BDFBB /* ja */, + 6F70E20D221058DF008BDFB7 /* es */, 6FE1765521C90BBE002690EA /* Base */, ); name = Localizable.strings; diff --git a/sync-translations.sh b/sync-translations.sh index 26b64f8..c855aab 100755 --- a/sync-translations.sh +++ b/sync-translations.sh @@ -23,11 +23,14 @@ done < Sources/WireGuardApp/Base.lproj/Localizable.strings git add Sources/WireGuardApp/*.lproj declare -A LOCALE_MAP +[[ $(< WireGuard.xcodeproj/project.pbxproj) =~ [[:space:]]([0-9A-F]{24})\ /\*\ Base\ \*/, ]] +base_id="${BASH_REMATCH[1]:0:16}" +idx=$(( "0x${BASH_REMATCH[1]:16}" )) while read -r filename; do l="$(basename "$(dirname "$filename")" .lproj)" [[ $l == Base ]] && continue - read -r -n 24 hex < <(LC_ALL=C tr -dc "A-F0-9" < /dev/urandom) - LOCALE_MAP["$l"]="$hex" + ((++idx)) + LOCALE_MAP["$l"]="$(printf '%s%08X' "$base_id" $idx)" done < <(find Sources/WireGuardApp -name Localizable.strings -type f) inkr=0 inls=0 inlsc=0 @@ -43,6 +46,7 @@ while IFS= read -r line; do echo "$line" printf '\t\t\t\tBase,\n\t\t\t\ten,\n' for l in "${!LOCALE_MAP[@]}"; do + [[ $l == *-* ]] && l="\"$l\"" printf '\t\t\t\t%s,\n' "$l" done inkr=1