CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-i18next-client

tessl install tessl/npm-i18next-client@1.11.0

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

Agent Success

Agent success rate when using this tile

69%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.08x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-5/

Custom Translation Logger

Build a custom logger plugin for an internationalization system that tracks translation lookups and missing keys for debugging purposes.

Requirements

Create a translation system that:

  1. Implements a custom logger plugin that captures all translation events
  2. Registers the custom logger with the i18n framework
  3. Tracks successful translation lookups and missing translation keys
  4. Provides methods to retrieve logged events for debugging

The logger should maintain separate lists for successful lookups and missing keys, allowing developers to identify translation gaps during development.

Test Cases

  • Successfully logs a translation lookup when a key is found @test
  • Records missing key events when translations are not found @test
  • Allows retrieval of all logged events @test
  • Works with multiple translation namespaces @test

Implementation

@generates

API

/**
 * Custom logger plugin for i18next that tracks translation events
 */
class TranslationLogger {
  /**
   * Creates a new translation logger instance
   */
  constructor();

  /**
   * Gets the plugin type identifier
   * @returns {string} The type of plugin ('logger')
   */
  get type();

  /**
   * Initializes the logger with i18next services
   * @param {object} services - i18next services object
   * @param {object} options - Logger options
   */
  init(services, options);

  /**
   * Logs general messages
   * @param {...any} args - Arguments to log
   */
  log(...args);

  /**
   * Logs warning messages
   * @param {...any} args - Arguments to log
   */
  warn(...args);

  /**
   * Logs error messages
   * @param {...any} args - Arguments to log
   */
  error(...args);

  /**
   * Gets all successful translation lookups
   * @returns {Array<{key: string, namespace: string, language: string}>} Array of lookup records
   */
  getSuccessfulLookups();

  /**
   * Gets all missing translation keys
   * @returns {Array<{key: string, namespace: string, language: string}>} Array of missing keys
   */
  getMissingKeys();

  /**
   * Clears all logged events
   */
  clear();
}

/**
 * Initializes i18next with the custom logger and sample translations
 * @param {TranslationLogger} logger - The custom logger instance
 * @returns {Promise<object>} Initialized i18next instance
 */
async function initializeI18n(logger);

module.exports = {
  TranslationLogger,
  initializeI18n
};

Dependencies { .dependencies }

i18next { .dependency }

Provides internationalization framework with plugin support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/i18next-client@1.11.x
tile.json