AUR4000

Error Message

AUR4000: Translation key not found

Description

This error occurs when the i18n system cannot find a translation for the requested key in any of the loaded translation resources. This typically happens when:

  1. The translation key doesn't exist in the current locale's translation files

  2. The translation files haven't been loaded properly

  3. There's a typo in the translation key

  4. The fallback locale doesn't contain the key either

Common Scenarios

Missing Translation Key

// Translation file (en.json)
{
  "welcome": "Welcome",
  "goodbye": "Goodbye"
}

// Template usage
<template>
  <p>${'hello' & t}</p> <!-- AUR4000: 'hello' key doesn't exist -->
  <p>${'welcome' & t}</p> <!-- ✅ Works fine -->
</template>

Typo in Translation Key

// ❌ Wrong: Typo in key
<p>${'welcom' & t}</p> <!-- Missing 'e' at the end -->

// ✅ Correct: Proper key
<p>${'welcome' & t}</p>

Solutions

1. Add the Missing Translation Key

// en.json
{
  "welcome": "Welcome",
  "hello": "Hello",
  "goodbye": "Goodbye"
}

2. Verify Translation Files Are Loaded

import { I18N } from '@aurelia/i18n';

export class MyApp {
  constructor(private i18n: I18N) {}
  
  async attached() {
    // Ensure translations are loaded
    await this.i18n.setLocale('en');
  }
}

3. Use Fallback Values

<!-- Provide fallback text -->
<p>${'missing-key' & t : 'Default Text'}</p>

4. Check Key Existence Programmatically

export class MyComponent {
  constructor(private i18n: I18N) {}
  
  getTranslation(key: string) {
    if (this.i18n.tr.hasKey(key)) {
      return this.i18n.tr(key);
    }
    return `Missing translation: ${key}`;
  }
}

Debugging Tips

  1. Check Console: Look for i18n loading errors in browser console

  2. Verify File Structure: Ensure translation files are in the correct location

  3. Test Key Existence: Use browser dev tools to check loaded translations

  4. Fallback Locale: Ensure fallback locale contains all necessary keys

Last updated

Was this helpful?