on 04-03-2020 7:02 AM
Hello,
I was wondering if there is any mechanism to make use of the i18n resource bundle defined in a CAP service, from inside a NodeJS based service implementation? Its usage would be similar to how resource bundles are used in SAPUI5 Javascript controllers and Components.
Thanks,
Ashish
well, it kinda works in CAP (v 3.33.1) in NodeJS
const i18n = require('@sap/cds/lib/models/i18n')
var sBlubb = cds.localize({_i18nfolders:[__dirname + "/../_i18n"]}, "de", "\"{i18n>blubb}\"")
Note that the string MUST contain the double quotes around the binding {...} and the result also has the double quotes inside of the string
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe the CAP Community should think about using the @sap/textbundle package.
CC: christian.georgi vansyckel daniel.hutzel
nice. I did a search but only ever found other localization packages based on different other formats for bundle files.
I support the Idea that CAP should be using it internally. And definitely will give it a try myself (currently using a self-made wrapper including parametrizing messages a la formatMessage("hello {0}", ['world']))
You could try to use this npm package in your custom hook functions:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.