AUR4002

Error Message

AUR4002: Expected the i18n key to be a string, but got {{value}} of type {{type}}

Description

This error occurs when a non-string value is passed as a translation key. The i18n system expects all translation keys to be strings.

Common Scenarios

// ❌ Wrong: Non-string key
const key = 123;
const translated = i18n.tr(key); // AUR4002

// ❌ Wrong: Undefined/null key
const key = undefined;
const translated = i18n.tr(key); // AUR4002

Solution

// ✅ Correct: String key
const key = 'welcome';
const translated = i18n.tr(key);

// ✅ Correct: Convert to string if needed
const numericId = 123;
const key = `item_${numericId}`;
const translated = i18n.tr(key);

Last updated

Was this helpful?