Skip to content

Commit

Permalink
Add ability to fix missing translations and unsupported characters; a…
Browse files Browse the repository at this point in the history
…pply it automatically when packing the image
  • Loading branch information
Michael Belyaev committed Apr 26, 2024
1 parent 50871cd commit 6d28284
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Localidiff/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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])}");
Expand All @@ -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.
""");
}
15 changes: 15 additions & 0 deletions pack-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

0 comments on commit 6d28284

Please sign in to comment.