Interface MissingPolicy
- All Known Implementing Classes:
AndroidMissingPolicy
,CompositeMissingPolicy
,PseudoTranslationPolicy
,SourceStringPolicy
,WrappedStringPolicy
public interface MissingPolicy
An interface for classes that determine what translation is returned when the requested
translation is not available.
-
Method Summary
Modifier and TypeMethodDescriptionget
(Resources resources, CharSequence sourceString, int id, String resourceName, String locale) Return a string as a translation based on the given source string.getQuantityString
(Resources resources, CharSequence sourceQuantityString, int id, int quantity, String resourceName, String locale) Return a quantity string as a translation based on the given source quantity string and quantity.
-
Method Details
-
get
@NonNull CharSequence get(@NonNull Resources resources, @NonNull CharSequence sourceString, @StringRes int id, @NonNull String resourceName, @NonNull String locale) Return a string as a translation based on the given source string.Classes that implement this interface may choose to return anything relevant to the given source string or not, based on their custom policy.
- 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 CharSequence getQuantityString(@NonNull Resources resources, @NonNull CharSequence sourceQuantityString, @PluralsRes int id, int quantity, @NonNull String resourceName, @NonNull String locale) Return a quantity string as a translation based on the given source quantity string and quantity.Classes that implement this interface may choose to return anything relevant to the given source string or not, based on their custom policy.
- 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.
-