petermuessig / typescript-app-and-lib-plus-npm-packages

TypeScript App connected to TypeScript UI Library plus using NPM packages
Apache License 2.0
6 stars 0 forks source link

Can not use SAPUI5 Text Repository within SAPUI5 Control Libraries #2

Open Kasde96 opened 2 months ago

Kasde96 commented 2 months ago

Hi @petermuessig,

I hope you’re doing well.

I’m reaching out to discuss a challenge we’re facing while implementing a SAPUI5 library in TypeScript deployed on a S/4 on premise system, following the guidelines from your recent git hub repo.

We aim to utilize the SAPUI5 Text Repository to centrally manage and customize customer-specific translations. Since we are developing an SAP Add-On in SAPUI5/RAP, it's crucial for us to translate the localized texts within the backend itself, rather than translating the i18n texts directly in the frontend application. We are specifically looking to leverage the Text Repository as outlined in the following documentation: SAPUI5 Text Repository. Currently, we are implementing a "Reusable Library" that will include both controls and simple TypeScript classes for reuse across our applications.

However, we have encountered an important issue: While the text repository was successfully created and translated in SE63, it is not displayed correctly in the Launchpad for the deployed app within the loaded library, instead the default texts from "messagebundle.properties" are displayed.

Do you have any idea or suggestion how to solve this issue?

Best regards,

Dominik Kastenmeier

petermuessig commented 3 weeks ago

Hi @Kasde96

sorry, it's hard for me to follow up all the channels - I saw it initially but I forgot to follow up on your issue. Did you solve this issue in the meantime?

When the default texts are loaded it means that the translated files haven't been found and in your network trace you should see 404 responses. BTW: I assume you deploy the built library?! In this case the problem is related to the supportedLocales information in the manifest.json which is being generated during the build:

{
  [...]
  "sap.ui5": {
    [...]
    "library": {
      "i18n": {
        "bundleUrl": "messagebundle.properties",
        "supportedLocales": [
          ""
        ],
        "fallbackLocale": ""
      },

If it looks like this, the UI5 runtime will not load other i18n files besides the default bundle as the list of supportedLocales only contains the empty string value (which represents the default messagebundle).

You need to read the following documentation for it: https://sap.github.io/ui5-tooling/stable/pages/Builder/#generation-of-supported-locales. But if a library, like in your case doesn't contain a manifest.json as it is being generated, there's no option so far to tell the UI5 tooling to override the supportedLocales.

A simple and pragmatic option would be to create empty messagebundle_*.properties for the local build and skip them for the deployment.

@codeworrior @RandomByte @matz3 @flovogt - something to think about to allow the injection of the supportedLocales via other configuration or do you have an alternate idea? I think the ABAP case with the translation there we do not have in mind, right?

codeworrior commented 3 weeks ago

The solution recommended by the UI5 tooling is to have a manifest as source in your library (or app) and to maintain the list of supporteLocales on your own. The tooling then will no longer determine the locales from the existing *.properties files.

petermuessig commented 3 weeks ago

@codeworrior Ok, should we update our library templates then to always have a manifest included? As we want to go to manifest first this would be in general not bad to have the manifest always available as source...

petermuessig commented 3 weeks ago

@Kasde96 the solution for you then would be to take the generated manifest.json and copy it into your libraries source code and modify the supportedLocales there.