Class ContextLocaleHelper

java.lang.Object
com.broadleafcommerce.translation.mapping.ContextLocaleHelper

public class ContextLocaleHelper extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getExplicitContextLocaleForTranslation(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 the trackableBehavior is application or catalog trackable, return whether the contextLocale matches against the contextInfo's application or catalog default, respectively.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 context
      contextInfo - 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 the trackableBehavior is application or catalog trackable, return whether the contextLocale matches against the contextInfo's application or catalog default, respectively.
      Parameters:
      trackableBehavior - The trackable behavior to consider in the context
      contextInfo - The context info to check application or catalog default against
      contextLocale - The locale from the contextInfo
      Returns:
      If the trackableBehavior is application or catalog discriminated, return whether the contextLocaleCode matches against the contextInfo's application or catalog default, respectively.