in library/src/main/java/com/whatsapp/stringpacks/PluralRules.java [805:829]
public static PluralRules ruleForLocale(@NonNull Locale locale) {
final String language = locale.getLanguage();
final String region = locale.getCountry();
PluralRules rules;
if (!region.isEmpty()) {
// Try both language and region first, if there's a region (Portuguese rules differ based on
// region).
rules = allRules.get(language + "_" + region);
if (rules != null) {
return rules;
}
}
// Now try just the language.
rules = allRules.get(language);
if (rules != null) {
return rules;
}
// Still not found. Return the default rule, which is an "other"-only rule.
rules = allRules.get("root");
if (rules != null) {
return rules;
}
// If root doesn't exist, we are broken beyond repair.
throw new NullPointerException("No plural rule found for 'root' locale.");
}