Class ContextLocaleHelper
java.lang.Object
com.broadleafcommerce.translation.mapping.ContextLocaleHelper
A helper to determine if the locale of the context is not the default for the current application
or catalog context, and if so, returns this explicitly defined locale.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetExplicitContextLocaleForTranslation
(com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage trackableBehavior, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the locale for translation from the current context if it's not already the the default, and if translations are not ignored.protected boolean
localeMatchesApplicationOrCatalog
(com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage trackableBehavior, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Locale contextLocale) If thetrackableBehavior
is application or catalog trackable, return whether thecontextLocale
matches against thecontextInfo
's application or catalog default, respectively.
-
Constructor Details
-
ContextLocaleHelper
public ContextLocaleHelper()
-
-
Method Details
-
getExplicitContextLocaleForTranslation
@Nullable public Locale getExplicitContextLocaleForTranslation(@NonNull com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage trackableBehavior, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve the locale for translation from the current context if it's not already the the default, and if translations are not ignored.- Parameters:
trackableBehavior
- The trackable behavior to consider in the contextcontextInfo
- The context info to check application or catalog default against- Returns:
- The explicit context locale for translation if not default or ignored
-
localeMatchesApplicationOrCatalog
protected boolean localeMatchesApplicationOrCatalog(@NonNull com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage trackableBehavior, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @NonNull Locale contextLocale) If thetrackableBehavior
is application or catalog trackable, return whether thecontextLocale
matches against thecontextInfo
's application or catalog default, respectively.- Parameters:
trackableBehavior
- The trackable behavior to consider in the contextcontextInfo
- The context info to check application or catalog default againstcontextLocale
- The locale from the contextInfo- Returns:
- If the
trackableBehavior
is application or catalog discriminated, return whether thecontextLocaleCode
matches against thecontextInfo
's application or catalog default, respectively.
-