Configuration
Every option of the Lang module, and the frontend flag that makes your app's translations writable.
The module reads its options from its entry in antelope.config.ts. ajs project modules add keys that entry by the package name.
"@antelopejs/dms-lang": {
source: { type: "package", package: "@antelopejs/dms-lang", version: "<latest>" },
config: {
editable: true,
},
},
Module options
| Option | Type | Default | Description |
|---|---|---|---|
editable | boolean | false | Allows the running process to create, rename and delete workspaces, add and remove languages, and write keys and translations. When false, every write route answers 403 with the read_only error, and the pages show the texts without editors. |
workspacesDir | string | the module's i18n-workspaces folder | Where the workspaces you create are stored. The backend resolves a relative path against its working directory. A reinstall of the module wipes the default folder. A folder outside the module's install folder, such as a folder of your project, keeps the workspaces through a reinstall or an upgrade. |
editable belongs on the processes where people translate, such as development or a staging back office. A production process that serves the public locale files usually stays read-only.
Frontend module options
The Project files workspace edits the locale files of the frontend modules flagged as the application layer. The flag goes in the options of AddFrontendModule:
| Option | Type | Description |
|---|---|---|
dmsI18nAppLayer | boolean | Marks the frontend module's locale files as the writable project files. The locale files of other frontend modules, such as the DMS and installed modules, stay read-only in the Installed modules workspace. |
Locale files follow the DMS adapter convention. Each is one JSON file per namespace and locale, named <name>-<xx-XX>.json, such as app-en-GB.json or lang-fr-FR.json. Lang ignores a file named otherwise, such as app-it.json or en.json.
Without a layers directory, Lang scans the module's i18n/locales directory recursively. When layers exists, Lang scans layers/*/i18n/locales instead, including the subfolders of each locale directory. It then ignores the module's root i18n/locales, even when layers is empty. The registry groups files by the two-letter language code, so en-GB and en-US both count as en and are not separate regional locales.
Project files
A flagged module may hold any number of files per language, such as app-en-GB.json alone, or one file per domain such as demo-en-GB.json, crm-en-GB.json and team-en-GB.json. Lang merges them per language in path order, after the files of lower-priority flagged modules. A later file wins on a key that both files define.
For each language, a write from the Project files workspace goes to the first match in this list:
- The file that defines the key. When several files define it, the one whose value shows. An edit lands where the key already lives.
- For a key that no file of that language defines yet, the file that holds the longest part of its namespace.
crm.deals.titlegoes to the file that already hascrm.deals, else to the one that hascrm. - When no file shares its namespace, the last file named exactly
app-<xx-XX>.jsonin merge order. A domain file such asapp-crm-en-GB.jsonis not an app fallback. - Without an exact app fallback, the last file of the language in merge order.
A renamed key stays in the file that defined it. A new language comes from a new <name>-<xx-XX>.json file next to the others.
Deleting a key, clearing its value or dropping an override removes only the winning definition in each affected language. If another project file defines the same key, its value becomes visible again. Renaming also moves only the winning definition, so an older definition can keep the source key visible. A key disappears completely only once no other project file defines it. Duplicate definitions belong only where you intend layered overrides.
Storage and public URL
| What | Where |
|---|---|
| Workspaces you create | <workspacesDir>/<workspace>/, one <locale>.json per language and a .workspace.json manifest. The default workspacesDir is the module's i18n-workspaces folder. |
| Public files | GET <apiBaseUrl>/i18n/<workspace>/<locale>.json, open to any origin, Cache-Control: no-cache |
| Public origin | The DMS apiBaseUrl (the dev server's origin in development) |
| Through the dashboard | The module declares /i18n/** to the frontend server as a backend prefix without a session (backendProxies: [{ path: "/i18n/**", auth: "none" }]), so the same files also answer on the dashboard's origin |
Changing workspacesDir does not move existing workspaces. Their directories, manifests included, have to be copied to the new location before the configuration switches. The backend process needs read access to the folder, and write access when editing is on. Workspaces kept on persistent storage, with backups, survive a server move.
Only the workspaces you create are served publicly. The project files ship with the dashboard bundle, and the modules workspace is read from the installed packages.