Package com.transifex.txnative
Class TxNative.Initializer
java.lang.Object
com.transifex.txnative.TxNative.Initializer
- Enclosing class:
- TxNative
Builder class for initializing the SDK.
-
Constructor Summary
ConstructorsConstructorDescriptionInitializer(Context applicationContext, LocaleState locales, String token) Creates an Initializer with mandatory parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidinit()Initializes the TransifexNative SDK with the configured parameters.Sets the translation cache that holds the translations from the CDS.withCdsHost(String cdsHost) Sets an optional host for the Content Delivery Service.withCustomAuthorizationHeaderKey(String customAuthorizationHeaderKey) Sets a custom key for the HTTP Header used for passing the token to the Content Delivery Service.withMissingPolicy(MissingPolicy missingPolicy) Sets the missing policy that determines how to handle translations that are not available.
-
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
Sets an optional host for the Content Delivery Service. If set tonull, 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 tonull, the default key is used.- Parameters:
customAuthorizationHeaderKey- The custom authorization key.- Returns:
- The Initializer instance for chaining.
-
withCache
Sets the translation cache that holds the translations from the CDS. If set tonull,TxStandardCacheis used.- Parameters:
cache- The translation cache.- Returns:
- The Initializer instance for chaining.
-
withMissingPolicy
Sets the missing policy that determines how to handle translations that are not available. If set tonull,SourceStringPolicyis used.- Parameters:
missingPolicy- The missing policy.- Returns:
- The Initializer instance for chaining.
-