Class LocaleUtils

java.lang.Object
com.sap.cds.services.utils.LocaleUtils

public class LocaleUtils extends Object
Utility class to handle the locale settings
  • Constructor Details

  • 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 parameter
      acceptLanguageHeader - Value of accepted language header parameter
      sapLanguageQueryParam - Value of "sap-language"query parameter
      xSapLanguageHeader - Value of "x-sap-request-language" query parameter
      Returns:
      the locale
    • getLocalizedEntityName

      public static String getLocalizedEntityName(String entity)
      Calculates the localized entity name that can be used to access localized fields
      Parameters:
      entity - the entity name
      Returns:
      the localized entity name
    • getLocaleStringForQuery

      public static String getLocaleStringForQuery(Locale locale)
      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

      public static Locale getLocaleForBundle(Locale locale)
      Determines the locale used for resource bundle lookups
      Parameters:
      locale - the locale
      Returns:
      the locale to beused for bundle lookup