Class UserPortalLocalizationsHelper
- java.lang.Object
-
- de.xima.fc.gui.helper.user_portal.UserPortalLocalizationsHelper
-
public class UserPortalLocalizationsHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddCustomLocalizationsKeyForSelected(UserPortalViewModel model, ELocalizationsType type)static voidapplyLocalizations(Map<Locale,LocalizationsViewModel> localizationsModel, ILocalizationProviding<?,?> localizationProviding)Applies the given localizations model to the given localization providing object.static List<Locale>createStandardLocales(Locale locale)Creates a list of well-known locales, sorted by the display name in the given locale.static List<String>findCustomSortedLocalizationKeysForSelected(UserPortalViewModel model, ELocalizationsType type)static Map<String,String>findCustomSortedPortalMessagesMapForLocale(UserPortalViewModel model, Locale locale)Finds all custom portal messages for the given locale in the user portal view model.static List<String>findLanguagesToAddMatchingQuery(String query, Locale locale, UserPortalViewModel model)Finds all languages that match the given query and are not yet added to the user portal.static voidremoveCustomKeyFromAlLocalizationsForSelected(UserPortalViewModel model, ELocalizationsType type, String key)static <E extends ILocalizationProviding<?,?> & ILocalizedScopedFilesProviding<?,?,?>>
voidremoveDeletedLocalizations(E object, ILocalizationsViewModelProviding.ILocalizationsViewModelProvidingWithFiles viewModel, UserPortalViewModel model)Removes deleted localizations and files from the given object based on the view model and available localesstatic <E extends ILocalizationProviding<?,?> & ILocalizedScopedFilesProviding<?,?,?>>
voidremoveDeletedLocalizedEntries(E object, ILocalizationsViewModelProviding.ILocalizationsViewModelProvidingWithFiles viewModel)Removes deleted localizations and files from the given object based only on the current view model state.static voidsetCustomPortalMessages(UserPortalViewModel model)Sets the custom portal messages for the user portal view model.static voidsetCustomPortalMessagesForLocale(UserPortalViewModel model, Locale locale)Sets the custom properties for the given locale in the user portal view model.
-
-
-
Method Detail
-
addCustomLocalizationsKeyForSelected
public static void addCustomLocalizationsKeyForSelected(UserPortalViewModel model, ELocalizationsType type)
-
createStandardLocales
public static List<Locale> createStandardLocales(Locale locale)
Creates a list of well-known locales, sorted by the display name in the given locale.- Parameters:
locale- The locale to use for sorting the locales, based on their display name.- Returns:
- A list of locales.
-
setCustomPortalMessages
public static void setCustomPortalMessages(UserPortalViewModel model)
Sets the custom portal messages for the user portal view model.- Parameters:
model- The user portal view model.
-
setCustomPortalMessagesForLocale
public static void setCustomPortalMessagesForLocale(UserPortalViewModel model, Locale locale)
Sets the custom properties for the given locale in the user portal view model. When a property is missing for a locale, it is added with an empty value. At the end, the custom properties for the selected locale are set.- Parameters:
model- The user portal view model.locale- the locale to set the custom properties for.
-
findCustomSortedPortalMessagesMapForLocale
public static Map<String,String> findCustomSortedPortalMessagesMapForLocale(UserPortalViewModel model, Locale locale)
Finds all custom portal messages for the given locale in the user portal view model.- Parameters:
model- The user portal view model.locale- The locale to find the custom portal messages for.- Returns:
- A map of custom portal messages.
-
findCustomSortedLocalizationKeysForSelected
public static List<String> findCustomSortedLocalizationKeysForSelected(UserPortalViewModel model, ELocalizationsType type)
-
applyLocalizations
public static void applyLocalizations(Map<Locale,LocalizationsViewModel> localizationsModel, ILocalizationProviding<?,?> localizationProviding)
Applies the given localizations model to the given localization providing object.- Parameters:
localizationsModel- the localizations modellocalizationProviding- the localization providing object
-
removeDeletedLocalizations
public static <E extends ILocalizationProviding<?,?> & ILocalizedScopedFilesProviding<?,?,?>> void removeDeletedLocalizations(E object, ILocalizationsViewModelProviding.ILocalizationsViewModelProvidingWithFiles viewModel, UserPortalViewModel model)
Removes deleted localizations and files from the given object based on the view model and available locales- Type Parameters:
E- The type of the object- Parameters:
object- The object to remove deleted localizations and files fromviewModel- The view model to check for existing localizations and filesmodel- The user portal view model to check for available locales
-
removeDeletedLocalizedEntries
public static <E extends ILocalizationProviding<?,?> & ILocalizedScopedFilesProviding<?,?,?>> void removeDeletedLocalizedEntries(E object, ILocalizationsViewModelProviding.ILocalizationsViewModelProvidingWithFiles viewModel)
Removes deleted localizations and files from the given object based only on the current view model state.Unlike
removeDeletedLocalizations(ILocalizationProviding, ILocalizationsViewModelProviding.ILocalizationsViewModelProvidingWithFiles, UserPortalViewModel)this method does not remove entries merely because their locale is not available in the current portal. This is needed for shared content entities (e.g. forms, resources, templates), whose translations may still be used by other portals.- Type Parameters:
E- The type of the object- Parameters:
object- The object to remove deleted localizations and files fromviewModel- The view model to check for existing localizations and files
-
findLanguagesToAddMatchingQuery
public static List<String> findLanguagesToAddMatchingQuery(String query, Locale locale, UserPortalViewModel model)
Finds all languages that match the given query and are not yet added to the user portal. The query is matched against the language tag and the display name of the locale.- Parameters:
query- Query to match against the language tags and display names.locale- Locale to use for sorting the languages based on their display name.model- User portal view model to find the languages for.- Returns:
- A list of language tags that match the query and are not yet added to the user portal.
-
removeCustomKeyFromAlLocalizationsForSelected
public static void removeCustomKeyFromAlLocalizationsForSelected(UserPortalViewModel model, ELocalizationsType type, String key)
-
-