Class TxNative.Initializer

java.lang.Object
com.transifex.txnative.TxNative.Initializer
Enclosing class:
TxNative

public static class TxNative.Initializer extends Object
Builder class for initializing the SDK.
  • Constructor Details

    • Initializer

      public Initializer(@NonNull Context applicationContext, @NonNull LocaleState locales, @NonNull String token)
      Creates an Initializer with mandatory parameters.
      Parameters:
      applicationContext - The application context.
      locales - Configures the locales supported by the SDK.
      token - The Transifex token that can be used for retrieving translations from CDS.
  • Method Details

    • init

      public void init()
      Initializes the TransifexNative SDK with the configured parameters.
      Throws:
      RuntimeException - if the SDK has already been initialized.
    • withCdsHost

      public TxNative.Initializer withCdsHost(@Nullable String cdsHost)
      Sets an optional host for the Content Delivery Service. If set to null, the production host provided by Transifex is used.
      Parameters:
      cdsHost - The CDS host.
      Returns:
      The Initializer instance for chaining.
    • withCustomAuthorizationHeaderKey

      public TxNative.Initializer withCustomAuthorizationHeaderKey(@Nullable String customAuthorizationHeaderKey)
      Sets a custom key for the HTTP Header used for passing the token to the Content Delivery Service. If set to null, the default key is used.
      Parameters:
      customAuthorizationHeaderKey - The custom authorization key.
      Returns:
      The Initializer instance for chaining.
    • withCache

      public TxNative.Initializer withCache(@Nullable TxCache cache)
      Sets the translation cache that holds the translations from the CDS. If set to null, TxStandardCache is used.
      Parameters:
      cache - The translation cache.
      Returns:
      The Initializer instance for chaining.
    • withMissingPolicy

      public TxNative.Initializer withMissingPolicy(@Nullable MissingPolicy missingPolicy)
      Sets the missing policy that determines how to handle translations that are not available. If set to null, SourceStringPolicy is used.
      Parameters:
      missingPolicy - The missing policy.
      Returns:
      The Initializer instance for chaining.