From 6d28284cc0aeaec202fa0f36441bc8b13ab265be Mon Sep 17 00:00:00 2001 From: Michael Belyaev Date: Fri, 26 Apr 2024 18:06:01 +0300 Subject: [PATCH] Add ability to fix missing translations and unsupported characters; apply it automatically when packing the image --- Localidiff/Program.cs | 20 +++++++++++++++----- pack-update.sh | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Localidiff/Program.cs b/Localidiff/Program.cs index 6df83c9..c436350 100644 --- a/Localidiff/Program.cs +++ b/Localidiff/Program.cs @@ -127,6 +127,10 @@ void Compare(string oldPath, string newPath) } File.WriteAllLines(args[1]!, dict!.OrderByDescending(pair => pair.Key == "//").ThenBy(pair => pair.Key).Select(pair => FormatLine(pair.Value) + "\r"), UTF16LE); } +else if (args.Length == 2 && args[0] == "replace-unsupported-characters") +{ + File.WriteAllText(args[1], File.ReadAllText(args[1], UTF16LE).Replace('і', 'i'), UTF16LE); +} else if (args.Length == 2) { Console.WriteLine($"FILE\t{Path.GetFileName(args[0])}"); @@ -136,16 +140,22 @@ void Compare(string oldPath, string newPath) { Console.WriteLine(""" Usage: - Localidiff 1.txt 2.txt + localidiff 1.txt 2.txt Compares 2.txt to 1.txt and outputs the patch into the standard output - Localidiff unused 1.txt unused unused 2.txt unused unused + localidiff unused 1.txt unused unused 2.txt unused unused The same but for usage as a git difftool - Localidiff apply patch.patch + localidiff apply patch.patch Applies patch.patch - Localidiff copy-missing-strings file.txt destination-language source-language - Copies missing translations from source-language to destination-language in file.txt. Languages are specified as column numbers. + localidiff copy-missing-strings file.txt destination-language source-language + Copies missing translations from source-language to destination-language in file.txt. Languages are specified as column numbers, where the first language (English) is 0. + + localidiff replace-unsupported-characters + Replaces known characters missing in the font with their graphic analogs. + + localidiff fix-bom + Adds byte-order mark to UTF-16LE file. """); } diff --git a/pack-update.sh b/pack-update.sh index d25e04b..b99c901 100755 --- a/pack-update.sh +++ b/pack-update.sh @@ -18,6 +18,18 @@ fi UPDATE_FILE=$1 rm -f "$UPDATE_FILE" +rm -Rf "$UPDATE_FILE.dump/Language.bak" +cp -R "$UPDATE_FILE.dump/data_udisk/apps/Language" "$UPDATE_FILE.dump/Language.bak" +for file in "$UPDATE_FILE.dump/data_udisk/apps/Language"/*.txt +do + localidiff replace-unsupported-characters "$file" + localidiff copy-missing-strings "$file" 21 9 + for language in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + do + localidiff copy-missing-strings "$file" $language 0 + done +done + export ASAN_OPTIONS=detect_leaks=0 echo "Packing $UPDATE_FILE.dump/data_udisk into MINFS image $UPDATE_FILE.dump/data_udisk.fex" @@ -31,3 +43,6 @@ echo "Updating checksum of $UPDATE_FILE.dump/melis_pkg_nor.fex in $UPDATE_FILE.d echo "Packing $UPDATE_FILE.dump into update image $UPDATE_FILE" "$SCRIPT_DIR"/bin/awimage -v -n "$UPDATE_FILE.dump" + +rm -Rf "$UPDATE_FILE.dump/data_udisk/apps/Language" +mv "$UPDATE_FILE.dump/Language.bak" "$UPDATE_FILE.dump/data_udisk/apps/Language"