code: public static Locale getLocaleToBeUsed(final UiProperties.Localization localizationProperties,
              final Locale desiredLocale) {
          final List<String> availableLocals = localizationProperties.getAvailableLocals();
          // ckeck if language code of UI locale matches an available local.
          // Country, region and variant are ignored. "availableLocals" must only
          // contain language codes without country or other extensions.
          if (availableLocals.contains(desiredLocale.getLanguage())) {
              return desiredLocale;
          }
          return new Locale(localizationProperties.getDefaultLocal());
      }
docs: Determine the language that should be used considering localization
  properties and a desired Locale
  
  @param localizationProperties
  UI Localization settings
  @param desiredLocale
  desired Locale
  @return Locale to be used according to UI and properties