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-9/

User Notification System

Build a notification system that displays personalized messages with dynamic content. The system should support multiple languages and inject user-specific data into message templates.

Requirements

Your system should:

  1. Display welcome messages with the user's name inserted dynamically
  2. Show notification messages with multiple dynamic values (e.g., count and item names)
  3. Support nested data interpolation where values come from nested object properties
  4. Provide fallback values when expected data is missing

The system should support at least English and Spanish translations.

Implementation

@generates

API

/**
 * Initializes the notification system with translation resources
 * @param {Object} resources - Translation resources organized by language
 * @returns {Promise<void>}
 */
async function initNotifications(resources);

/**
 * Gets a personalized greeting with the user's name
 * @param {string} language - Language code (e.g., 'en', 'es')
 * @param {string} userName - The user's name to insert
 * @returns {string} Localized greeting with user name
 */
function getGreeting(language, userName);

/**
 * Gets a notification message with multiple dynamic values
 * @param {string} language - Language code
 * @param {Object} data - Object containing count and itemName properties
 * @returns {string} Localized notification with interpolated values
 */
function getNotification(language, data);

/**
 * Gets a message using nested object data
 * @param {string} language - Language code
 * @param {Object} data - Nested object with user.profile.name structure
 * @returns {string} Localized message with nested interpolation
 */
function getProfileMessage(language, data);

Test Cases

  • Calling getGreeting('en', 'Alice') returns "Welcome, Alice!" @test
  • Calling getGreeting('es', 'Carlos') returns "¡Bienvenido, Carlos!" @test
  • Calling getNotification('en', {count: 5, itemName: 'messages'}) returns "You have 5 new messages" @test
  • Calling getProfileMessage('en', {user: {profile: {name: 'Bob'}}}) returns a message containing "Bob" from nested data @test
  • Calling getGreeting('en', undefined) returns a greeting with a default name like "Guest" when no name is provided @test

Dependencies { .dependencies }

i18next { .dependency }

Provides internationalization with interpolation support for dynamic content in translations.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-i18next-client

tile.json