on 2019 Jul 11 6:34 PM
Hi
I have a gateway service that needs to service users with different languages, and the best way I have found is to implement a method to fetch the language from request header.
But the downside is that I have to include this method call in every enitity implemented and therefore this is often called multiple times per request.
Is there a way to set the language as a global attribute in the gateway object modea and prehap redifine some base class method to set the language automatically in every request ?
METHOD get_language.
DATA : lo_facade TYPE REF TO /iwbep/if_mgw_dp_int_facade,
lt_client_headers TYPE tihttpnvp,
lw_client_headers LIKE LINE OF lt_client_headers.
TRY.
lo_facade ?= /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
lt_client_headers = lo_facade->get_request_header( ).
CATCH /iwbep/cx_mgw_tech_exception.
ENDTRY.
LOOP AT lt_client_headers INTO lw_client_headers WHERE name = 'accept-language'.
IF lw_client_headers-value CS 'en'.
ov_language = 'E'.
ELSEIF lw_client_headers-value CS 'pl'.
ov_language = 'L'.
ENDIF.
ENDLOOP.
SET LANGUAGE ov_language.
sy-langu = ov_language.
ENDMETHOD.
Request clarification before answering.
The frontend determine automatically the lenguaje from browser configuration, if you need to change this default lenguage you can use a parameter in URL or using sapui5 library:
With code:
sap.ui.getCore().getConfiguration().setLanguage("de");
With parameters:
sap-language=DE
And in order to use this language in the gateway is only necessary indicates this language at logon
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
9 | |
8 | |
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.