Class WrappedStringPolicy
java.lang.Object
com.transifex.txnative.missingpolicy.WrappedStringPolicy
- All Implemented Interfaces:
MissingPolicy
Wraps the source string with a custom format.
Example:
new WrappedStringPolicy(">>", "<<").get("Click here");
Returns:
">>Click here<<"
-
Constructor Summary
ConstructorsConstructorDescriptionWrappedStringPolicy(String start, String end) Creates a new instance with the provided strings. -
Method Summary
Modifier and TypeMethodDescriptionget(Resources resources, CharSequence sourceString, int id, String resourceName, String locale) Returns a wrapped string.getQuantityString(Resources resources, CharSequence sourceQuantityString, int id, int quantity, String resourceName, String locale) Returns a wrapped quantity string.
-
Constructor Details
-
WrappedStringPolicy
Creates a new instance with the provided strings.- Parameters:
start- The string to prepend the source String. Can benull.end- The string to append to the source string. Can benull.
-
-
Method Details
-
get
@NonNull public CharSequence get(@NonNull Resources resources, @NonNull CharSequence sourceString, @StringRes int id, @NonNull String resourceName, @NonNull String locale) Returns a wrapped string.- Specified by:
getin interfaceMissingPolicy- Parameters:
resources- A Resources object. This is the base resources object returned byTxResources.getBaseResources().sourceString- The source string.id- The string resource identifier as defined byResources.getIdentifier(String, String, String).resourceName- The entry name of the string resource as defined byResources.getResourceEntryName(int).locale- The current locale as returned byLocaleState.getResolvedLocale().- Returns:
- The translated string.
-
getQuantityString
@NonNull public CharSequence getQuantityString(@NonNull Resources resources, @NonNull CharSequence sourceQuantityString, @PluralsRes int id, int quantity, @NonNull String resourceName, @NonNull String locale) Returns a wrapped quantity string.- Specified by:
getQuantityStringin interfaceMissingPolicy- Parameters:
resources- A Resources object. This is the base resources object returned byTxResources.getBaseResources().sourceQuantityString- The source string having grammatically correct pluralization for the given quantity.id- The plurals resource identifier as defined byResources.getIdentifier(String, String, String).quantity- The number used to get the correct string for the current language's plural rules.resourceName- The entry name of the plurals resource as defined byResources.getResourceEntryName(int).locale- The current locale as returned byLocaleState.getResolvedLocale().- Returns:
- The translated string.
-