Files
wxWidgets/misc/languages/data/unicode/uni_genscriptmap.lua
T
Ulrich Telle 57e1c9e1ee Update wxWidgets language database and improve locale matching
This commit improves the best locale match algorithm by prioritizing
closer matches and add many new tests verifying that this works as
expected.

In order to do this, new information had to be added to the language
database, which was extended with it and updated to use the latest
Unicode CLDR data and latest Windows 11 locale list.

Further, add a set of scripts for maintaining the language database up
to date and a GitHub workflow `genlangdb.yml` which can be run manually
to regenerate the wxWidgets language-related source and header files
from the underlying Windows and Unicode data. It produces 2 artifacts:

- wxLanguageDatabaseDist.zip allows to easily update the
  language-related files in the wxWidgets repository by simply copying
  all files.
- the normal workflow log and wxLanguageDatabaseLog.zip allow to check
  all temporary files of the regeneration process and to detect
  potential issues, before the language-related files are actually
  replaced by the new ones.

Finally, fix wxUILocaleImplName::GetPreferredUILanguages: Under Windows
10 and above the Windows API function ::GetUserPreferredUILanguages()
returns only the primary UI language plus US English. Additional
preferred UI languages installed by the user are ignored, so instead of
using this function read the list of user preferred languages from the
Windows registry.

Closes #24855.
2024-11-18 16:46:25 +01:00

72 lines
2.2 KiB
Lua

-- Generate a script map based on ISO 15924 data
--
-- Data source: Unicode
-- URL: https://www.unicode.org/iso15924/iso15924.txt
-- License: UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
codeFileName = "unicode/iso15924.txt"
function split(str, character)
result = {}
index = 1
for s in string.gmatch(str .. character, "(.-)"..character) do
result[index] = s
index = index + 1
end
return result
end
fo2 = io.open('temp/uni_loadscriptmap.sql','w')
fo2:write('-- Mapping of script codes based on ISO 15924\n-- Date: ' .. os.date("%Y-%m-%d %H:%M") .. '\n\n')
fo2:write('-- Data source: Unicode Org (https://www.unicode.org)\n')
fo2:write('-- URL: https://www.unicode.org/iso15924/iso15924.txt\n')
fo2:write('-- License: UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE\n\n')
fo2:write("create table if not exists uni_scriptmap (sctag char, scname char, scalias char, primary key (sctag));\n")
fo2:write('delete from uni_scriptmap;\nbegin;\n')
-- Names and order of data columns
-- Code|N°|English Name|Nom français|Alias|Age|Date
noalias = 0
count = 0
for line in io.lines(codeFileName) do
rem = string.sub(line,1,1)
if rem ~= "#" and rem ~= "" then
values = split(line, ";")
sctag = values[1]
scnum = values[2]
scname = values[3]
scname_fr = values[4]
scalias = values[5]
scage = values[6]
scdate = values[7]
scname = scname:gsub("'", "''")
if scalias == "" then
if sctag == "Hans" or sctag == "Hant" then
scalias = sctag
else
noalias = noalias + 1
scalias = "-"
end
end
fo2:write("insert into uni_scriptmap values ('" .. sctag .. "', '" .. scname .. "', '" .. scalias .. "');\n")
count = count + 1
end
end
print(" Number of script mappings = " .. count)
print(" Number of missing script aliases = " .. noalias)
if noalias > 0 then
print(" Script aliases are used in POSIX locale identifiers where they are")
print(" used as modifiers to represent the script of a language.")
print(" Missing script aliases impose a problem only for script identifiers")
print(" actually used in locale tags supported by wxWidgets.")
end
fo2:write('commit;\n')
fo2:close()