Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions examples/supplier-onboarding-i18n/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# Supplier onboarding in 15 locales with TeaQL Java

The [KSML model](model.xml) describes a warehouse with suppliers. The [semantic model](semantics.json) sends two registrations through the generated workspace. One lacks a supplier name. The other submits 3 as the minimum order quantity, below the allowed value of 10. The application attempts audited saves and uses generated Q to confirm that SQLite stores neither invalid supplier.
The KSML model: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/examples/supplier-onboarding-i18n/model.xml describes a warehouse with suppliers. The semantic model: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/examples/supplier-onboarding-i18n/semantics.json sends two registrations through the generated workspace. One lacks a supplier name. The other submits 3 as the minimum order quantity, below the allowed value of 10. The application attempts audited saves and uses generated Q to confirm that SQLite stores neither invalid supplier.

## AI-translated business vocabulary

The model bundle includes vocabulary.json: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/examples/supplier-onboarding-i18n/vocabulary.json, authored by OpenAI Codex for all 15 locales. It translates every entity and field label, including supplier name and minimum order quantity. The model selects it with `i18n_catalog="vocabulary.json"`. Supply both files when regenerating the workspace. The generator writes these labels into the application catalog and the Checker presentation metadata embedded in the generated library. The example checks the actual error text for the selected locale’s field label. A translated sentence with an untranslated English field label fails verification.

## Run and select a locale

JDK 21, Maven 3.9, Git, and Python 3.9 or newer. This example uses local Java SDK 6.3.0 source. The runner builds the local Java SDK, generated library and shaded console in temporary directories. Maven settings are supplied by the runner and resolve third-party dependencies through Maven Central.
JDK 21, Maven 3.9, Git, and Python 3.9 or newer. The model targets the Java 6.3.0 API baseline. The runner reads the version of the selected local SDK source and builds all TeaQL dependencies with that version, including the current local SDK. The runner builds the local Java SDK, generated library and shaded console in temporary directories. Maven settings are supplied by the runner and resolve third-party dependencies through Maven Central.

```sh
bash examples/supplier-onboarding-i18n/run.sh
bash examples/supplier-onboarding-i18n/run.sh --locale fr
bash examples/supplier-onboarding-i18n/run.sh --all
bash examples/supplier-onboarding-i18n/run.sh --edge-cases
bash examples/supplier-onboarding-i18n/run.sh --verify
git clone --branch examples-i18n-15-locales-v1 https://github.com/teaql/teaql-java.git
cd teaql-java/examples/supplier-onboarding-i18n
bash run.sh
bash run.sh --locale ar
bash run.sh --all
bash run.sh --edge-cases
bash run.sh --verify
```

The commands run from the runtime repository root. The output is UTF-8 JSON Lines. Each validation row gives the effective locale, stable message key, canonical field, native rule, arguments and localized message. `--all` uses the 15 locales from the semantic model in one process. The final command runs the full set twice against one SQLite file and runs the locale boundary checks.
The clone command creates `teaql-java` in your current directory. The next command enters its supplier example directory. Run the following `bash run.sh` commands there. The article snapshot is pinned by the source tag `examples-i18n-15-locales-v1`. The output is UTF-8 JSON Lines. Each validation row gives the effective locale, stable message key, canonical field, native rule, arguments and localized message. `--all` uses the 15 locales from the semantic model in one process. The final command runs the full set twice against one SQLite file and runs the locale boundary checks.

The app selects the locale with `context.setLocaleCode(code)` and reads `context.locale().code()`. A new context defaults to `en`. The parser trims, normalizes underscores and case, and resolves known aliases such as `ZH_hant` to `zh-TW`. An empty or unsupported code raises `UnsupportedLocaleException` and preserves the previous locale. Single-language mode prints the rejection and exits 2. Locale selection comes from the trusted CLI and context. Environment variables and business input do not set it.

Expand All @@ -27,13 +33,17 @@ The app selects the locale with `context.setLocaleCode(code)` and reads `context
3. The renderer chooses the locale and a template for the field's location shape. It binds the rendered field, model path and applicable checker parameters, including the lower bound.
4. The sample attaches the generated application catalog through `context.installI18nCatalog(I18nCatalog.fromJson(input))`. Its Vietnamese message entries are absent. Built-in Vietnamese supplies the same two messages after attachment. For this natural checker message, selection tries the application's shape-specific override, the application legacy template, and the built-in natural template at the active locale, then repeats that order for English. The generic invalid rule can supply the final natural template. Direct lookup through the legacy message catalog selects application and built-in entries at the current locale first, then application and built-in English, then the stable key.

The independent French context remains French through the main context's Japanese, Arabic and Japanese sequence. Domain labels without an available translation can remain in English. The original rule enum is uppercase. The example exposes the language-neutral keys alongside it. [Locale source](../../teaql-core/src/main/java/io/teaql/core/i18n/Locale.java) · [Message lookup source](../../teaql-core/src/main/java/io/teaql/core/i18n/I18nCatalog.java) · [Natural templates source](../../teaql-core/src/main/java/io/teaql/core/i18n/CheckerMessageCatalog.java)
The independent French context remains French through the main context's Japanese, Arabic and Japanese sequence. All labels used by this example have explicit translations in its model vocabulary. The original rule enum is uppercase. The example exposes the language-neutral keys alongside it. Locale source: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/teaql-core/src/main/java/io/teaql/core/i18n/Locale.java · Message lookup source: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/teaql-core/src/main/java/io/teaql/core/i18n/I18nCatalog.java · Natural templates source: https://github.com/teaql/teaql-java/blob/examples-i18n-15-locales-v1/teaql-core/src/main/java/io/teaql/core/i18n/CheckerMessageCatalog.java

## Run the same scene in another runtime

Keep the same KSML and semantic inputs when switching to its sibling checkout. Each runtime uses its own setup and call style, while the error keys, field paths and minimum bound stay stable.
Keep the same KSML model, semantic inputs and AI vocabulary when switching runtimes. The refreshed article examples are available at these complete URLs:

https://github.com/teaql/teaql-java/tree/examples-i18n-15-locales-v1/examples/supplier-onboarding-i18n

https://github.com/teaql/teaql-rs/tree/examples-i18n-15-locales-v1/examples/supplier-onboarding-i18n

[Java](./README.md) · [Rust](../../../rust/examples/supplier-onboarding-i18n/README.md) · [TypeScript](../../../typescript/examples/supplier-onboarding-i18n/README.md) · [Go](../../../go/examples/supplier-onboarding-i18n/README.md) · [Python](../../../python/examples/supplier-onboarding-i18n/README.md) · [C#/.NET](../../../dotnet/examples/supplier-onboarding-i18n/README.md) · [Swift](../../../swift/Examples/SupplierOnboardingI18n/README.md)
The complete 15-locale, two-error message table is included in `messages.md` in this directory.

## Add a locale

Expand Down
18 changes: 9 additions & 9 deletions examples/supplier-onboarding-i18n/generated-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"lib/src/main/java/com/teaql/supplieronboardingservice/Checkers.java": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"lib/src/main/java/com/teaql/supplieronboardingservice/Constants.java": "0cfcf3aa558ed8b55ca71f567ede299f9a95227b63d7300e16032e7a5f046dac",
"lib/src/main/java/com/teaql/supplieronboardingservice/E.java": "79ff3cb2cfad2143120ba4a627db0afc1a5f964213d42ef5d8f432b6c30050c5",
"lib/src/main/java/com/teaql/supplieronboardingservice/EntityMetaRegistry.java": "1c7f64b2ddc6fdd70463c9e09ffb0fe37ed312a8cd8609b088c1cb2a01f55e6b",
"lib/src/main/java/com/teaql/supplieronboardingservice/GeneratedRuntimeModule.java": "f52540b74ce9e6ed0dd8c8b46657f8539617944a5b3e813fdf3a8c68f459bf82",
"lib/src/main/java/com/teaql/supplieronboardingservice/EntityMetaRegistry.java": "8b7d66f275b6d9df1eab30fce3e711ccb4e5013dc8130233c6a5aaee6b1b3907",
"lib/src/main/java/com/teaql/supplieronboardingservice/GeneratedRuntimeModule.java": "b1044e70509517724c0105db9ddea8055aff87e25861688b8499a79b22e9e570",
"lib/src/main/java/com/teaql/supplieronboardingservice/Q.java": "5da716e058711d26d9c0040670349b936f5dae6a117402d29d64cb3a8e96789c",
"lib/src/main/java/com/teaql/supplieronboardingservice/Repositories.java": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"lib/src/main/java/com/teaql/supplieronboardingservice/SupplierOnboardingServiceUserContext.java": "ff9511a4d5363fec480beda8c58a8b1c988b672e2ea7ed3eb0e2aa3cc955b441",
Expand All @@ -24,8 +24,8 @@
"lib/src/main/java/com/teaql/supplieronboardingservice/warehouse/WarehouseListExpression.java": "a27a8efffb98747eea8b95cee7f8e2d79d1c11446e9ef85da778fcc613c75e67",
"lib/src/main/java/com/teaql/supplieronboardingservice/warehouse/WarehouseRequest.java": "e61584951aaaacff2175a8b3f753b5b62465a22ff327ef263cb6350c22f81657",
"lib/src/main/resources/META-INF/services/io.teaql.core.meta.EntityMetaAssembler": "c699cbbe9f6d75cebf1253969a8537f8be80ed3b1637040a2392a74b6292539d",
"teaql/checker-model.json": "0c70836b868047e6bbf8c5a4b167343ef9425e5c535c59ee388b634a79f2b144",
"teaql/model-provenance.json": "94ae1b99943275455fce8de247c97f10a81cdb09fef91ada0ae924b26e572759"
"teaql/checker-model.json": "e1e6711e7493501c604fa095818ec2a2e1d51e137d5afb2674b3a9e852848037",
"teaql/model-provenance.json": "8b7e6d5c31dffe0eb18e181dd99d90fff8a4beebe1aee78168ec8097fd979e43"
}
},
"schema": "teaql.i18n-showcase-generation/v1",
Expand All @@ -47,8 +47,8 @@
"lib/src/main/java/com/teaql/supplieronboardingservice/Checkers.java": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"lib/src/main/java/com/teaql/supplieronboardingservice/Constants.java": "0cfcf3aa558ed8b55ca71f567ede299f9a95227b63d7300e16032e7a5f046dac",
"lib/src/main/java/com/teaql/supplieronboardingservice/E.java": "79ff3cb2cfad2143120ba4a627db0afc1a5f964213d42ef5d8f432b6c30050c5",
"lib/src/main/java/com/teaql/supplieronboardingservice/EntityMetaRegistry.java": "1c7f64b2ddc6fdd70463c9e09ffb0fe37ed312a8cd8609b088c1cb2a01f55e6b",
"lib/src/main/java/com/teaql/supplieronboardingservice/GeneratedRuntimeModule.java": "f52540b74ce9e6ed0dd8c8b46657f8539617944a5b3e813fdf3a8c68f459bf82",
"lib/src/main/java/com/teaql/supplieronboardingservice/EntityMetaRegistry.java": "8b7d66f275b6d9df1eab30fce3e711ccb4e5013dc8130233c6a5aaee6b1b3907",
"lib/src/main/java/com/teaql/supplieronboardingservice/GeneratedRuntimeModule.java": "b1044e70509517724c0105db9ddea8055aff87e25861688b8499a79b22e9e570",
"lib/src/main/java/com/teaql/supplieronboardingservice/Q.java": "5da716e058711d26d9c0040670349b936f5dae6a117402d29d64cb3a8e96789c",
"lib/src/main/java/com/teaql/supplieronboardingservice/Repositories.java": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"lib/src/main/java/com/teaql/supplieronboardingservice/SupplierOnboardingServiceUserContext.java": "ff9511a4d5363fec480beda8c58a8b1c988b672e2ea7ed3eb0e2aa3cc955b441",
Expand All @@ -69,9 +69,9 @@
"src/main/java/com/teaql/supplieronboardingservice/CustomUserContext.java": "30c31ae5c588e98b2ff6b6821b4022be0528640290eb21de5d727c52d6aa3c63",
"src/main/java/com/teaql/supplieronboardingservice/WorkspaceTeaQLDatabase.java": "a7838bb83fe4b65b1ada7a39cd83cd60b466b312ef2a1b65a2a8aa9e9172db9b",
"src/main/resources/application.properties": "a6206b7e5aea2807617fdffd65a9218373bd2d4d4077ca39c744141e1d2302b8",
"teaql-i18n.json": "f848093c0785f2730eaa74f8a9e175e1f90943f056d84666bc964d56668e298c",
"teaql/checker-model.json": "0c70836b868047e6bbf8c5a4b167343ef9425e5c535c59ee388b634a79f2b144",
"teaql/model-provenance.json": "94ae1b99943275455fce8de247c97f10a81cdb09fef91ada0ae924b26e572759"
"teaql-i18n.json": "63100d819a0238ed9746da7f542673f100527257f29040b0e73b7553e8c3be1d",
"teaql/checker-model.json": "e1e6711e7493501c604fa095818ec2a2e1d51e137d5afb2674b3a9e852848037",
"teaql/model-provenance.json": "8b7e6d5c31dffe0eb18e181dd99d90fff8a4beebe1aee78168ec8097fd979e43"
}
}
}
2 changes: 1 addition & 1 deletion examples/supplier-onboarding-i18n/java-app-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<libversion>0.0.1-SNAPSHOT</libversion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.parameters>true</maven.compiler.parameters>
<teaql.version>6.4.0</teaql.version>
<teaql.version>6.3.0</teaql.version>
</properties>

<repositories>
Expand Down
Loading
Loading