You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’d like to propose a new feature for a CLI tool designed for SAP CAP projects that can significantly streamline i18n (internationalization) management.
The idea is simple but powerful:
Scan JavaScript code in a CAP project (*.js) to automatically identify all points where messages are used, such as:
cds.i18n.messages.at()
cds.i18n.label.at()
throw new Error()
req.error() / `req.reject() / ...
Generate or update i18n files for the desired languages based on the messages found in the code.
Optional AI integration: Allow sending messages to an AI (like GPT or Joule) to:
Translate messages automatically
Suggest contextual messages
Generate messages from scratch based on the code context
Example JavaScript Usage
The CLI would detect messages like 'Mandatory field', update the relevant i18n files (en.json, pt-BR.json), and optionally send them to AI to generate smarter translations or context-aware messages.
functionverifyMandatoryFields(req){if(!req.data.field1){req.error('Mandatory field')// or throw new Error('msg'), req.reject, etc.}}
Message Extraction Example
The CLI will extract the text 'Mandatory field' and generate an entry in the i18n or messages file, for example:
Path to the directory containing the JavaScript (*.js) files to scan for messages. Example: ./srv
--out
-o
Path to the output directory where the generated or updated i18n files will be saved. Example: ./i18n
--lang
-l
Comma-separated list of languages for which to generate i18n files. Example: en,pt-BR
--ai
N/A
Optional flag to send detected messages to an AI (like GPT or SAP Joule) for translation, context-aware suggestions, or message generation from scratch.
--config
-c
Path to a JSON configuration file containing all CLI options in one place, including input, output, languages, AI settings, and other flags. Example: ./cds-i18n-config.json
Configuration Example for i18n
You can configure the CLI using a JSON file to manage i18n extraction and AI-assisted translation. Here's an example:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposed CLI Feature for SAP CAP i18n
I’d like to propose a new feature for a CLI tool designed for SAP CAP projects that can significantly streamline i18n (internationalization) management.
The idea is simple but powerful:
Scan JavaScript code in a CAP project (
*.js) to automatically identify all points where messages are used, such as:cds.i18n.messages.at()cds.i18n.label.at()throw new Error()req.error()/ `req.reject() / ...Generate or update i18n files for the desired languages based on the messages found in the code.
Optional AI integration: Allow sending messages to an AI (like GPT or Joule) to:
Example JavaScript Usage
Message Extraction Example
The CLI will extract the text
'Mandatory field'and generate an entry in the i18n or messages file, for example:with entry:
ERROR_MESSAGE_FIELD1=Mandatory field
Example CLI Usage
or
CLI Options Explanation
--in-i*.js) files to scan for messages. Example:./srv--out-o./i18n--lang-len,pt-BR--ai--config-c./cds-i18n-config.jsonConfiguration Example for i18n
You can configure the CLI using a JSON file to manage i18n extraction and AI-assisted translation. Here's an example:
{ "input": "./srv", "output": "./i18n", "languages": ["pt-BR", "en", "es"], "ai": { "provider": "openai", "model": "gpt-4o-mini", "apiKey": "env:OPENAI_API_KEY" }, "replaceOriginalText": true }Basic real CLI example for cds-i18n
Does this idea seem feasible to you? Would it make sense in a real SAP CAP project workflow?
Beta Was this translation helpful? Give feedback.
All reactions