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

Multi-Context Greeting System

Build a greeting system that provides contextually appropriate greetings based on formality level and time of day. The system should support multiple languages and use context to select the appropriate greeting variation.

Requirements

Create a greeting system with the following capabilities:

  1. Context-aware greetings: Generate greetings that change based on two context dimensions:

    • Formality: formal or informal
    • Time of day: morning, afternoon, or evening
  2. Multi-language support: Support English (en) and Spanish (es)

  3. Personalized greetings: Include the person's name in the greeting message

Implementation

Your implementation should:

  • Initialize an internationalization system with translation resources for both languages
  • Store translations with context variations (e.g., formal morning greetings differ from informal evening greetings)
  • Implement a getGreeting() function that selects the appropriate translation based on language and context parameters
  • Use variable interpolation to insert the person's name into the greeting

@generates

API

/**
 * Initializes the greeting system with translation resources
 * @returns {Promise<void>} Resolves when initialization is complete
 */
async function initGreetingSystem();

/**
 * Gets a contextually appropriate greeting
 * @param {string} name - The name of the person to greet
 * @param {string} language - The language code ('en' or 'es')
 * @param {string} formality - The formality level ('formal' or 'informal')
 * @param {string} timeOfDay - The time of day ('morning', 'afternoon', or 'evening')
 * @returns {string} The appropriate greeting message
 */
function getGreeting(name, language, formality, timeOfDay);

module.exports = {
  initGreetingSystem,
  getGreeting
};

Test Cases

  • When requesting an informal morning greeting in English for "Alice", it returns a casual morning greeting message with the name @test
  • When requesting a formal evening greeting in Spanish for "Carlos", it returns a respectful evening greeting message with the name @test
  • When requesting an informal afternoon greeting in English for "Bob", it returns a casual afternoon greeting message with the name @test
  • When requesting a formal morning greeting in Spanish for "Maria", it returns a respectful morning greeting message with the name @test

Dependencies { .dependencies }

i18next { .dependency }

Provides internationalization and context-based translation support.

Install with Tessl CLI

npx tessl i tessl/npm-i18next-client

tile.json