mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
chore(resources): prepare scripts for updating CLDR from latest v45
- make the updater script a little clearer - double check the correct version of CLDR is being imported - prepare to support multiple CLDR version streams
This commit is contained in:
parent
33da6d0f66
commit
322e987d5d
4 changed files with 67 additions and 11 deletions
60
resources/standards-data/ldml-keyboards/45/fetch-latest-cldr.sh → resources/standards-data/ldml-keyboards/fetch-latest-cldr.sh
Executable file → Normal file
60
resources/standards-data/ldml-keyboards/45/fetch-latest-cldr.sh → resources/standards-data/ldml-keyboards/fetch-latest-cldr.sh
Executable file → Normal file
|
|
@ -7,25 +7,43 @@
|
|||
|
||||
set -eu
|
||||
|
||||
if [[ $# -ne 1 ]];
|
||||
if [[ $# -ne 2 ]];
|
||||
then
|
||||
echo >&2 "Usage: $0 <cldr-dir>"
|
||||
echo >&2 "Usage: $0 <cldr-major> <cldr-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## START STANDARD BUILD SCRIPT INCLUDE
|
||||
# adjust relative paths as necessary
|
||||
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
. "${THIS_SCRIPT%/*}/../../../../resources/build/build-utils.sh"
|
||||
. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh"
|
||||
## END STANDARD BUILD SCRIPT INCLUDE
|
||||
|
||||
. "$KEYMAN_ROOT/resources/build/jq.inc.sh"
|
||||
|
||||
cd "$THIS_SCRIPT_PATH"
|
||||
|
||||
KEYMAN_CORE_LDML="../../../core/include/ldml"
|
||||
|
||||
builder_echo debug "Building ${KEYMAN_CORE_LDML}"
|
||||
|
||||
"${KEYMAN_CORE_LDML}/build.sh" || builder_die "building core/include/ldml failed"
|
||||
|
||||
KEYMAN_CORE_LDML_JS="${KEYMAN_CORE_LDML}/build/keyman_core_ldml.js"
|
||||
|
||||
if [ ! -f "${KEYMAN_CORE_LDML_JS}" ];
|
||||
then
|
||||
builder_die "Could not read ${KEYMAN_CORE_LDML_JS} - check build."
|
||||
fi
|
||||
|
||||
CLDR_VERSION="$1"
|
||||
shift
|
||||
|
||||
CLDR_DIR="$1"
|
||||
shift
|
||||
|
||||
node verify-version.mjs "${CLDR_VERSION}" || builder_die "Check CLDR version"
|
||||
|
||||
KEYBOARDS_DIR="${CLDR_DIR}/keyboards"
|
||||
DTD_DIR="${KEYBOARDS_DIR}/dtd"
|
||||
IMPORT_DIR="${KEYBOARDS_DIR}/import"
|
||||
|
|
@ -51,8 +69,15 @@ GIT_DESCRIBE=$(cd "${CLDR_DIR}" && git describe HEAD || echo unknown)
|
|||
GIT_SHA=$(cd "${CLDR_DIR}" && git rev-parse HEAD || echo unknown)
|
||||
NOW=$(date -u -R)
|
||||
|
||||
echo "${CLDR_DIR}" - "${GIT_DESCRIBE}" - "${GIT_SHA}"
|
||||
echo "---"
|
||||
|
||||
builder_echo heading "Ready to copy v${CLDR_VERSION} from ${CLDR_DIR}"
|
||||
builder_echo debug "${GIT_DESCRIBE} - ${GIT_SHA}"
|
||||
|
||||
mkdir -pv "${CLDR_VERSION}"
|
||||
|
||||
cd "${CLDR_VERSION}"
|
||||
|
||||
pwd
|
||||
|
||||
# delete the old files in case some were removed from CLDR
|
||||
rm -rf ./import ./3.0 ./dtd ./test
|
||||
|
|
@ -64,19 +89,32 @@ rm -vf dtd/{ldmlKeyboard,ldmlPlatform}.{xsd,dtd}
|
|||
|
||||
|
||||
echo "{\"sha\": \"${GIT_SHA}\",\"description\":\"${GIT_DESCRIBE}\",\"date\":\"${NOW}\"}" | ${JQ} . | tee cldr_info.json
|
||||
echo "Updated cldr_info.json"
|
||||
builder_echo "Updated cldr_info.json"
|
||||
|
||||
echo "Converting XSD to JSON…"
|
||||
builder_echo heading "Converting XSD to JSON…"
|
||||
|
||||
for xsd in dtd/*.xsd;
|
||||
do
|
||||
base=$(basename "${xsd}" .xsd | tr A-Z a-z | sed -e 's%^ldml%ldml-%g' )
|
||||
json=${base}.schema.json
|
||||
echo "${xsd} -> ${json}"
|
||||
(cd .. ; npx -p jgexml xsd2json 45/"${xsd}" 45/"${json}") || exit
|
||||
echo 'fixup-schema.js' "${json}"
|
||||
node fixup-schema.js "${json}" || builder_die "failed to fixup schema ${json}"
|
||||
builder_echo debug "${xsd} -> ${json}"
|
||||
(cd .. ; npx -p jgexml xsd2json ${CLDR_VERSION}/"${xsd}" ${CLDR_VERSION}/"${json}") || exit
|
||||
builder_echo debug 'fixup-schema.js' "${json}"
|
||||
node ../fixup-schema.js "${json}" || builder_die "failed to fixup schema ${json}"
|
||||
mv "${json}" tmp.json
|
||||
${JQ} . -S < tmp.json > "${json}" || (rm tmp.json ; builder_die "failed to transform final schema ${json}")
|
||||
rm tmp.json
|
||||
done
|
||||
|
||||
# verify that the CLDR version we just converted is the requested version.
|
||||
FOUND_VERSION=$(jq -r '.definitions.version.properties.cldrVersion.enum[0]' < ldml-keyboard3.schema.json)
|
||||
|
||||
if [ ${FOUND_VERSION} -ne ${CLDR_VERSION} ];
|
||||
then
|
||||
# It's a little late to cleanup more gracefully, but we can at least complain.
|
||||
builder_die "You requested CLDR ${CLDR_VERSION} but the copied schema is for ${FOUND_VERSION} - something is wrong."
|
||||
fi
|
||||
|
||||
echo
|
||||
builder_echo success "CLDR ${CLDR_VERSION} copied correctly from ${CLDR_DIR}"
|
||||
echo
|
||||
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
Data is versioned, so each directory has its version such as `45`.
|
||||
|
||||
## How to Update
|
||||
|
||||
- Checkout CLDR, preferably a release version, somewhere such as /src/cldr
|
||||
- run `fetch-latest-cldr.sh 45 /src/cldr` (where '45' is the CLDR version)
|
||||
- check results, run tests, check in and open a PR
|
||||
|
||||
## Data Format
|
||||
|
||||
Each directory contains:
|
||||
|
|
|
|||
12
resources/standards-data/ldml-keyboards/verify-version.mjs
Normal file
12
resources/standards-data/ldml-keyboards/verify-version.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import {constants} from '../../../core/include/ldml/build/keyman_core_ldml.js';
|
||||
import { argv } from 'node:process';
|
||||
|
||||
const args = argv.slice(2);
|
||||
const { cldr_version_latest } = constants;
|
||||
const ver = args[0];
|
||||
|
||||
if (cldr_version_latest !== ver) {
|
||||
throw Error(`Requester CLDR version '${ver}' but cldr_version_latest is '${cldr_version_latest}' - check keyman_core_ldml.ts`);
|
||||
} else {
|
||||
console.log(`CLDR version ${ver} OK`);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue