Package com.sap.cds.services.utils
Class LocaleUtils
java.lang.Object
com.sap.cds.services.utils.LocaleUtils
Utility class to handle the locale settings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLocale(String sapLocaleQueryParam, String acceptLanguageHeader, String sapLanguageQueryParam, String xSapLanguageHeader) Determines the locale for a request.static LocalegetLocaleForBundle(Locale locale) Determines the locale used for resource bundle lookupsstatic StringgetLocaleStringForQuery(Locale locale) Returns the correct locale String for the sap-language query parameterstatic StringgetLocalizedEntityName(String entity) Calculates the localized entity name that can be used to access localized fields
-
Constructor Details
-
LocaleUtils
-
-
Method Details
-
getLocale
public Locale getLocale(String sapLocaleQueryParam, String acceptLanguageHeader, String sapLanguageQueryParam, String xSapLanguageHeader) Determines the locale for a request.- Parameters:
sapLocaleQueryParam- Value of "sap-locale" query parameteracceptLanguageHeader- Value of accepted language header parametersapLanguageQueryParam- Value of "sap-language"query parameterxSapLanguageHeader- Value of "x-sap-request-language" query parameter- Returns:
- the locale
-
getLocalizedEntityName
Calculates the localized entity name that can be used to access localized fields- Parameters:
entity- the entity name- Returns:
- the localized entity name
-
getLocaleStringForQuery
Returns the correct locale String for the sap-language query parameter- Parameters:
locale- the locale- Returns:
- the correct locale String for the sap-language query parameter
-
getLocaleForBundle
Determines the locale used for resource bundle lookups- Parameters:
locale- the locale- Returns:
- the locale to beused for bundle lookup
-