From 297db925fc996beedd91835a23bf8fdc52354290 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 26 Aug 2021 08:31:31 -0400 Subject: [PATCH] LibUnicode: Extract cldr-numbers dataset from CLDR database This dataset holds the values needed to handle DisplayNames.prototype.of with a type option of "currency". --- .../CodeGenerators/GenerateUnicodeLocale.cpp | 2 ++ Userland/Libraries/LibUnicode/unicode_data.cmake | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeLocale.cpp b/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeLocale.cpp index fe825052e6..278f4ad23b 100644 --- a/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeLocale.cpp +++ b/Userland/Libraries/LibUnicode/CodeGenerators/GenerateUnicodeLocale.cpp @@ -437,11 +437,13 @@ int main(int argc, char** argv) char const* generated_header_path = nullptr; char const* generated_implementation_path = nullptr; char const* locale_names_path = nullptr; + char const* numbers_path = nullptr; Core::ArgsParser args_parser; args_parser.add_option(generated_header_path, "Path to the Unicode locale header file to generate", "generated-header-path", 'h', "generated-header-path"); args_parser.add_option(generated_implementation_path, "Path to the Unicode locale implementation file to generate", "generated-implementation-path", 'c', "generated-implementation-path"); args_parser.add_option(locale_names_path, "Path to cldr-localenames directory", "locale-names-path", 'l', "locale-names-path"); + args_parser.add_option(numbers_path, "Path to cldr-numbers directory", "numbers-path", 'n', "numbers-path"); args_parser.parse(argc, argv); auto open_file = [&](StringView path, StringView flags, Core::OpenMode mode = Core::OpenMode::ReadOnly) { diff --git a/Userland/Libraries/LibUnicode/unicode_data.cmake b/Userland/Libraries/LibUnicode/unicode_data.cmake index 15ccc8a588..a5bbec4fdb 100644 --- a/Userland/Libraries/LibUnicode/unicode_data.cmake +++ b/Userland/Libraries/LibUnicode/unicode_data.cmake @@ -43,6 +43,9 @@ set(CLDR_ZIP_PATH ${CLDR_PATH}/cldr.zip) set(CLDR_LOCALES_SOURCE cldr-localenames-modern) set(CLDR_LOCALES_PATH ${CLDR_PATH}/${CLDR_LOCALES_SOURCE}) +set(CLDR_NUMBERS_SOURCE cldr-numbers-modern) +set(CLDR_NUMBERS_PATH ${CLDR_PATH}/${CLDR_NUMBERS_SOURCE}) + if (ENABLE_UNICODE_DATABASE_DOWNLOAD) if (NOT EXISTS ${UNICODE_DATA_PATH}) message(STATUS "Downloading UCD UnicodeData.txt from ${UNICODE_DATA_URL}...") @@ -101,7 +104,14 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD) message(STATUS "Extracting CLDR ${CLDR_LOCALES_SOURCE} from ${CLDR_ZIP_PATH}...") execute_process(COMMAND unzip -q ${CLDR_ZIP_PATH} "${CLDR_LOCALES_SOURCE}/*" -d ${CLDR_PATH} RESULT_VARIABLE unzip_result) if (NOT unzip_result EQUAL 0) - message(FATAL_ERROR "Failed to unzip ${CLDR_ZIP_PATH} with status ${unzip_result}") + message(FATAL_ERROR "Failed to unzip ${CLDR_LOCALES_SOURCE} from ${CLDR_ZIP_PATH} with status ${unzip_result}") + endif() + endif() + if(EXISTS ${CLDR_ZIP_PATH} AND NOT EXISTS ${CLDR_NUMBERS_PATH}) + message(STATUS "Extracting CLDR ${CLDR_NUMBERS_SOURCE} from ${CLDR_ZIP_PATH}...") + execute_process(COMMAND unzip -q ${CLDR_ZIP_PATH} "${CLDR_NUMBERS_SOURCE}/*" -d ${CLDR_PATH} RESULT_VARIABLE unzip_result) + if (NOT unzip_result EQUAL 0) + message(FATAL_ERROR "Failed to unzip ${CLDR_NUMBERS_SOURCE} from ${CLDR_ZIP_PATH} with status ${unzip_result}") endif() endif() @@ -128,9 +138,9 @@ if (ENABLE_UNICODE_DATABASE_DOWNLOAD) add_custom_command( OUTPUT ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION} - COMMAND $ -h ${UNICODE_LOCALE_HEADER} -c ${UNICODE_LOCALE_IMPLEMENTATION} -l ${CLDR_LOCALES_PATH} + COMMAND $ -h ${UNICODE_LOCALE_HEADER} -c ${UNICODE_LOCALE_IMPLEMENTATION} -l ${CLDR_LOCALES_PATH} -n ${CLDR_NUMBERS_PATH} VERBATIM - DEPENDS GenerateUnicodeLocale ${CLDR_LOCALES_PATH} + DEPENDS GenerateUnicodeLocale ${CLDR_LOCALES_PATH} ${CLDR_NUMBERS_PATH} ) set(UNICODE_DATA_SOURCES ${UNICODE_DATA_HEADER} ${UNICODE_DATA_IMPLEMENTATION} ${UNICODE_LOCALE_HEADER} ${UNICODE_LOCALE_IMPLEMENTATION})