diff --git a/core/tests/unit/ldml/keyboards/meson.build b/core/tests/unit/ldml/keyboards/meson.build index 90860d01db6..25d5d12ac19 100644 --- a/core/tests/unit/ldml/keyboards/meson.build +++ b/core/tests/unit/ldml/keyboards/meson.build @@ -10,8 +10,7 @@ tests_from_cldr = [ 'ja-Latn', 'pt-t-k0-abnt2', - # 'fr-t-k0-optimise', (not yet) - 'fr-t-k0-azerty', + 'fr-t-k0-test', 'pcm', 'bn', ] diff --git a/resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-azerty.xml b/resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-test.xml similarity index 99% rename from resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-azerty.xml rename to resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-test.xml index a45e198e23b..eb4032db38d 100644 --- a/resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-azerty.xml +++ b/resources/standards-data/ldml-keyboards/45/3.0/fr-t-k0-test.xml @@ -2,7 +2,7 @@ - + diff --git a/resources/standards-data/ldml-keyboards/45/3.0/fr.xml b/resources/standards-data/ldml-keyboards/45/3.0/fr.xml new file mode 100644 index 00000000000..45871726c06 --- /dev/null +++ b/resources/standards-data/ldml-keyboards/45/3.0/fr.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/standards-data/ldml-keyboards/45/3.0/ja-Hira-t-k0-flicks.xml b/resources/standards-data/ldml-keyboards/45/3.0/ja-Hira-t-k0-flicks.xml new file mode 100644 index 00000000000..c10342320a0 --- /dev/null +++ b/resources/standards-data/ldml-keyboards/45/3.0/ja-Hira-t-k0-flicks.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/standards-data/ldml-keyboards/45/cldr_info.json b/resources/standards-data/ldml-keyboards/45/cldr_info.json index 0ac427a95bc..c7dd469c879 100644 --- a/resources/standards-data/ldml-keyboards/45/cldr_info.json +++ b/resources/standards-data/ldml-keyboards/45/cldr_info.json @@ -1,5 +1,5 @@ { - "sha": "40fa7fd5b074a203581d04ca0c0b004ab9aa491b", - "description": "release-45-alpha1-88-g40fa7fd5b0", - "date": "Fri, 01 Mar 2024 17:28:53 +0000" + "sha": "dd5776f650183c9172abe2a57313ed41619d41fb", + "description": "release-45", + "date": "Fri, 19 Apr 2024 22:23:26 +0000" } diff --git a/resources/standards-data/ldml-keyboards/45/dtd/ldmlKeyboard3.dtd b/resources/standards-data/ldml-keyboards/45/dtd/ldmlKeyboard3.dtd index 32765796906..618cf1cafd9 100644 --- a/resources/standards-data/ldml-keyboards/45/dtd/ldmlKeyboard3.dtd +++ b/resources/standards-data/ldml-keyboards/45/dtd/ldmlKeyboard3.dtd @@ -124,7 +124,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic - + @@ -133,13 +133,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic - + - + diff --git a/resources/standards-data/ldml-keyboards/45/import/keys-Latn-implied.xml b/resources/standards-data/ldml-keyboards/45/import/keys-Latn-implied.xml index 537860aeb93..fe0801f8ba9 100644 --- a/resources/standards-data/ldml-keyboards/45/import/keys-Latn-implied.xml +++ b/resources/standards-data/ldml-keyboards/45/import/keys-Latn-implied.xml @@ -1,8 +1,8 @@ + + + + + +``` + +Note: CLDR’s extensive [exemplar set](tr35-general.md#Character_Elements) data may be useful in validating a language’s repertoire against a keyboard. Tooling may wish to make use of this data in order to suggest recommended repertoire values for a language. + +### Test Element: tests + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [keyboardTest](#test-element-keyboardtest) +> +> Children: [_special_](tr35.md#special), [test](#test-element-test) +> +> Occurrence: Optional, Multiple +> + +This element specifies a particular suite of `` elements. + +_Attribute:_ `name` (required) + +This attribute value specifies a unique name for this suite of tests. These names could be output to the user during test execution, used to summarize success and failure, or used to select or deselect test components. + +**Example** + +```xml + + + … + + + … + + + + + … + + +``` + +### Test Element: test + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [tests](#test-element-tests) +> +> Children: [startContext](#test-element-startcontext), [emit](#test-element-emit), [keystroke](#test-element-keystroke), [backspace](#test-element-backspace), [check](#test-element-check), [_special_](tr35.md#special) +> +> Occurrence: Required, Multiple +> + +This attribute value specifies a specific isolated regression test. Multiple test elements do not interact with each other. + +The order of child elements is significant, with cumulative effects: they must be processed from first to last. + +_Attribute:_ `name` (required) + +This attribute value specifies a unique name for this particular test. These names could be output to the user during test execution, used to summarize success and failure, or used to select or deselect test components. + +**Example** + +```xml + +``` + +### Test Element: startContext + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + +This element specifies pre-existing text in a document, as if prior to the user’s insertion point. This is useful for testing transforms and reordering. If not specified, the startContext can be considered to be the empty string (""). + +> +> +> Parents: [test](#test-element-test) +> +> Children: _none_ +> +> Occurrence: Optional, Single +> + +_Attribute:_ `to` (required) + +Specifies the starting context. This text may be escaped with `\u` notation, see [Escaping](#escaping). + +**Example** + +```xml + +``` + + +### Test Element: keystroke + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [test](#test-element-test) +> +> Children: _none_ +> +> Occurrence: Optional, Multiple +> + +This element contains a single keystroke or other gesture event, identified by a particular key element. + +Optionally, one of the gesture attributes, either `flick`, `longPress`, or `tapCount` may be specified. If none of the gesture attribute values are specified, then a regular keypress is effected on the key. It is an error to specify more than one gesture attribute. + +If a key is not found, or a particular gesture has no definition, the output should be behave as if the user attempted to perform such an action. For example, an unspecified `flick` would result in no output. + +When a key is found, processing continues with the transform and other elements before updating the test output buffer. + +_Attribute:_ `key` (required) + +This attribute value specifies a key by means of the key’s `id` attribute. + +_Attribute:_ `flick` + +This attribute value specifies a flick gesture to be performed on the specified key instead of a keypress, such as `e` or `nw se`. This value corresponds to the `directions` attribute value of the [``](#element-flicksegment) element. + +_Attribute:_ `longPress` + +This attribute value specifies that a long press gesture should be performed on the specified key instead of a keypress. For example, `longPress="2"` indicates that the second character in a longpress series should be chosen. `longPress="0"` indicates that the `longPressDefault` value, if any, should be chosen. This corresponds to `longPress` and `longPressDefault` on [``](#element-key). + +_Attribute:_ `tapCount` + +This attribute value specifies that a multi-tap gesture should be performed on the specified key instead of a keypress. For example, `tapCount="3"` indicates that the key should be tapped three times in rapid succession. This corresponds to `multiTap` on [``](#element-key). The minimum tapCount is 2. + +**Example** + +```xml + + + + + +``` + +### Test Element: emit + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [test](#test-element-test) +> +> Children: _none_ +> +> Occurrence: Optional, Multiple +> + +This element also contains an input event, except that the input is specified in terms of textual value rather than key or gesture identity. This element is particularly useful for testing transforms. + +Processing of the specified text continues with the transform and other elements before updating the test output buffer. + +_Attribute:_ `to` (required) + +This attribute value specifies a string of output text representing a single keystroke or gesture. This string is intended to match the output of a `key`, `flick`, `longPress` or `multiTap` element or attribute. +Tooling should give a hint if this attribute value does not match at least one keystroke or gesture. Note that the specified text is not injected directly into the output buffer. + +This attribute value may be escaped with `\u` notation, see [Escaping](#escaping). + +**Example** + +```xml + +``` + + +### Test Element: backspace + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [test](#test-element-test) +> +> Children: _none_ +> +> Occurrence: Optional, Multiple +> + +This element contains a backspace action, as if the user typed the backspace key + +**Example** + +```xml + +``` + +### Test Element: check + +> **NOTE**: The Keyboard Test Data format is a technical preview, it is subject to revision in future versions of CLDR. + + +> +> +> Parents: [test](#test-element-test) +> +> Children: _none_ +> +> Occurrence: Optional, Multiple +> + +This element contains a check on the current output buffer. + +_Attribute:_ `result` (required) + +This attribute value specifies the expected resultant text in a document after processing this event and all prior events, and including any `startContext` text. This text may be escaped with `\u` notation, see [Escaping](#escaping). + +**Example** + +```xml + +``` + + +### Test Examples + +```xml + + + + + + + + + + + + + + + + + + + +``` + +## Copyright and License + +See the top level [README.md](../../README.md#copyright--licenses) diff --git a/resources/standards-data/ldml-keyboards/45/test/fr-t-k0-azerty-test.xml b/resources/standards-data/ldml-keyboards/45/test/fr-t-k0-test-test.xml similarity index 93% rename from resources/standards-data/ldml-keyboards/45/test/fr-t-k0-azerty-test.xml rename to resources/standards-data/ldml-keyboards/45/test/fr-t-k0-test-test.xml index 0228dae7c14..c03ce54362a 100644 --- a/resources/standards-data/ldml-keyboards/45/test/fr-t-k0-azerty-test.xml +++ b/resources/standards-data/ldml-keyboards/45/test/fr-t-k0-test-test.xml @@ -1,7 +1,7 @@ - + diff --git a/resources/standards-data/ldml-keyboards/45/fetch-latest-cldr.sh b/resources/standards-data/ldml-keyboards/fetch-latest-cldr.sh old mode 100755 new mode 100644 similarity index 53% rename from resources/standards-data/ldml-keyboards/45/fetch-latest-cldr.sh rename to resources/standards-data/ldml-keyboards/fetch-latest-cldr.sh index e12c8f8cbce..7234c69fb9f --- a/resources/standards-data/ldml-keyboards/45/fetch-latest-cldr.sh +++ b/resources/standards-data/ldml-keyboards/fetch-latest-cldr.sh @@ -7,25 +7,43 @@ set -eu -if [[ $# -ne 1 ]]; +if [[ $# -ne 2 ]]; then - echo >&2 "Usage: $0 " + echo >&2 "Usage: $0 " 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 diff --git a/resources/standards-data/ldml-keyboards/45/fixup-schema.js b/resources/standards-data/ldml-keyboards/fixup-schema.js similarity index 100% rename from resources/standards-data/ldml-keyboards/45/fixup-schema.js rename to resources/standards-data/ldml-keyboards/fixup-schema.js diff --git a/resources/standards-data/ldml-keyboards/readme.md b/resources/standards-data/ldml-keyboards/readme.md index aec3717571b..22189fcfd68 100644 --- a/resources/standards-data/ldml-keyboards/readme.md +++ b/resources/standards-data/ldml-keyboards/readme.md @@ -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: diff --git a/resources/standards-data/ldml-keyboards/verify-version.mjs b/resources/standards-data/ldml-keyboards/verify-version.mjs new file mode 100644 index 00000000000..0704155c93f --- /dev/null +++ b/resources/standards-data/ldml-keyboards/verify-version.mjs @@ -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`); +}