OrchardCMS/OrchardCore · error · PluralFormNotFoundException
Plural form ' ' doesn't exist for the key ' ' in the ' '…
Error message
Plural form '{pluralForm}' doesn't exist for the key '{key}' in the '{CultureName}' culture. What it means
CultureDictionary stores translations per plural form; when a caller requests a translation with a count whose computed plural rule index exceeds the stored translations array, the dictionary throws PluralFormNotFoundException. This indicates the PO/translation source does not provide all plural forms required by the culture's plural rule (e.g. only 2 forms stored for a culture needing 3).
Solutions
- Fix the translation source (PO file) so the key includes all plural forms required by the culture.
- Catch PluralFormNotFoundException and fall back to form 0 or the default string.
- Regenerate/validate translations with the culture's nplurals rule before importing.
- If you control the lookup, omit count so pluralForm resolves to 0 when a full set is unavailable.
Example fix
// before (PO msgstr with only 2 forms for a 3-form culture) msgstr[0] "..."; msgstr[1] "..." // after msgstr[0] "..."; msgstr[1] "..."; msgstr[2] "..."
Defensive patterns
Strategy: try-catch
Validate before calling
var translations = dictionary[key]; // validate count of forms loaded
if (translations?.Length <= culturePluralFormsCount) logger.LogWarning("Key {Key} missing plural forms for {Culture}", key, culture.Name); Try / catch
try { text = dictionary[key, count]; }
catch (PluralFormNotFoundException ex) { logger.LogWarning(ex, "Missing plural form; using fallback"); text = dictionary[key] ?? key; } Prevention
- Validate PO files cover all nplurals forms per culture before import
- Test localization for all supported cultures with counts 0..5
- Keep translations complete when adding new cultures
When it happens
Trigger: Accessing CultureDictionary indexer with a count whose PluralRule(count) returns an index >= translations.Length for the key, typically due to incomplete plural translations for languages with multiple plural forms.
Common situations: Importing PO files with missing plural entries, switching the site to a culture (Russian, Polish, Arabic) whose plural rule needs more forms than the translation provides, or hand-written translations omitting nplurals entries.
Related errors
- PluralForms array can't be empty, it must contain at least…
- PluralForms array can't be empty, it must contain at least…
- PluralForms array can't be empty, it must contain at least…
- The calendar is not supported.
- MessageId can't be empty.
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/952ac856b94377c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Localization.Abstractions/CultureDictionary.cs:59
/// <summary>
/// Gets the localized value.
/// </summary>
/// <param name="key">The resource key.</param>
/// <param name="count">The number to specify the pluralization form.</param>
/// <returns></returns>
public string this[CultureDictionaryRecordKey key, int? count]
{
get
{
if (!Translations.TryGetValue(key, out var translations))
{
return null;
}
var pluralForm = count.HasValue ? PluralRule(count.Value) : 0;
if (pluralForm >= translations.Length)
{
throw new PluralFormNotFoundException($"Plural form '{pluralForm}' doesn't exist for the key '{key}' in the '{CultureName}' culture.", new PluralForm(key, pluralForm, CultureInfo.GetCultureInfo(CultureName)));
}
return translations[pluralForm];
}
}
/// <summary>
/// Gets a list of the culture translations including the plural forms.
/// </summary>
public IDictionary<CultureDictionaryRecordKey, string[]> Translations { get; }
/// <summary>
/// Merges the translations from multiple dictionary records.
/// </summary>
/// <param name="records">The records to be merged.</param>
public void MergeTranslations(IEnumerable<CultureDictionaryRecord> records)
{
foreach (var record in records)View on GitHub (pinned to 4306c0717f)