geert-janklaps / cds-launchpad-plugin

Launchpad Plugin for demo / development / testing SAP CAP-based projects
MIT License
12 stars 13 forks source link

sap.app - i18n - bundleUrl not yet supported #8

Closed gregorwolf closed 1 year ago

gregorwolf commented 1 year ago

Hi @geert-janklaps,

I try to follow the best practice described in UI5ers Buzz #54: I18n with supportedLocales and fallbackLocale configuration and added the following to my manifest.json:

{
    "_version": "1.45.0",
    "sap.app": {
        "id": "environments",
        "type": "application",
        "i18n": {
            "bundleUrl": "i18n/i18n.properties",
            "supportedLocales": [
                "en"
            ],
            "fallbackLocale": "en"
        },

Unfortunately that causes this error:

ENOENT: no such file or directory, open '/app/environments/webapp/[object Object]'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at /node_modules/cds-launchpad-plugin/src/index.ts:93:31
    at Array.forEach (<anonymous>)
    at cds_launchpad_plugin.prepareAppConfigJSON (/node_modules/cds-launchpad-plugin/src/index.ts:73:25)
    at /node_modules/cds-launchpad-plugin/src/index.ts:34:34
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/node_modules/express/lib/router/index.js:328:13)
    at /node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/node_modules/express/lib/router/index.js:346:12)

I would suggest to look by default for:

let i18nPath = cds.root + '/' + element + '/webapp/' + manifest["sap.app"].i18n.bundleUrl;

and fallback only when empty to the current implementation. What do you think?

Best Regards Gregor

geert-janklaps commented 1 year ago

Hi @gregorwolf,

Sounds good to me! The idea behind this plugin is to have it support as much as possible of the standard configuration options, this is clearly one of them!

Do you have a pull request? Or you want me to implement this one?

Cheers, Geert-Jan

geert-janklaps commented 1 year ago

@gregorwolf: Version 1.0.8 is now published to npm! Thanks for the contribution!