on 09-13-2023 8:48 AM
Hello,
I know that I can attach arbitrary headers dynamically/at runtime in the Cloud SDK.
Is this also possible in the Java CAP environment?
I consume 3-4 standard APIs that provide a translation if I include a sap-language header. However, it can only be decided at runtime which language is desired. I can't find any option in the CQN API.
Does anyone know a possibility? Thanks!
CAP Java stores the current Locale in the RequestContext, see also https://pages.github.tools.sap/cap/docs/java/request-contexts
The Locale from the RequestContext is automatically added as sap-language query parameter or Accept-Language header when using the RemoteServices feature. Do you really need a sap-language header?
You can control and overwrite the Locale in the RequestContext, for example:
runtime.requestContext().modifyParameters(p -> p.setLocale(someLocale)).run(requestContext -> {
// execute CQN query in this scope
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marc,
thanks for this hint. I will try it.
The API translates the texts only if the header is set. URL parameter is ignored.
User | Count |
---|---|
70 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.