CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-i18next-client

DEPRECATED client-side JavaScript internationalization library with translation, pluralization, and localization support.

69

1.07x
Overview
Eval results
Files

task.mdevals/scenario-2/

Multi-Language Application Settings Manager

Build a settings manager for a multi-language application that properly initializes an internationalization system with support for multiple languages, namespaces, and fallback behavior.

Requirements

Your task is to implement a settings manager that:

  1. Initializes the internationalization system with English as the default language and support for Spanish and French
  2. Configures two separate namespaces: "common" for general UI text and "settings" for settings-specific text
  3. Sets up a fallback language chain so that if a translation is missing in the current language, it falls back to English
  4. Preloads all three supported languages during initialization
  5. Enables debug mode to help with development
  6. Returns the initialized instance for use by other parts of the application

Implementation

@generates

API

/**
 * Initializes and returns a configured i18n instance for the application.
 *
 * The instance should be configured with:
 * - Default language: 'en'
 * - Supported languages: ['en', 'es', 'fr']
 * - Namespaces: ['common', 'settings'] with 'common' as default
 * - Fallback language: 'en'
 * - Debug mode: enabled
 * - All languages preloaded
 *
 * @returns {Promise<Object>} A promise that resolves to the initialized i18n instance
 */
async function initializeI18n() {
  // IMPLEMENTATION HERE
}

module.exports = {
  initializeI18n
};

Test Cases

  • The initialization function returns a promise that resolves to an i18n instance @test
  • The initialized instance has English ('en') as the current language @test
  • The initialized instance supports the 'common' and 'settings' namespaces @test
  • When a translation key is missing in Spanish, it falls back to the English translation @test

Dependencies { .dependencies }

i18next { .dependency }

Provides internationalization framework with translation, configuration, and language management capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-i18next-client

tile.json