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

Settings Locale Manager

A utility that manages application settings with internationalization support, handling structured configuration data including nested objects and arrays.

Capabilities

Retrieve nested settings using dot notation

  • Given a translation resource with nested structure {"app": {"theme": {"color": "blue"}}}, accessing with key "app.theme.color" returns "blue" @test
  • Given a deeply nested structure {"settings": {"user": {"preferences": {"language": "en"}}}}, accessing "settings.user.preferences.language" returns "en" @test

Return entire configuration objects

  • Given a translation resource {"menu": {"file": "File", "edit": "Edit"}}, accessing key "menu" returns the entire object {"file": "File", "edit": "Edit"} @test
  • Given nested structure {"colors": {"primary": {"light": "#fff", "dark": "#000"}}}, accessing "colors.primary" returns {"light": "#fff", "dark": "#000"} @test

Return configuration arrays

  • Given a translation resource {"options": ["Option A", "Option B", "Option C"]}, accessing key "options" returns the array ["Option A", "Option B", "Option C"] @test
  • Given nested structure {"menu": {"items": ["Home", "About", "Contact"]}}, accessing "menu.items" returns the array ["Home", "About", "Contact"] @test

Handle ignoreJSONStructure configuration

  • When ignoreJSONStructure is set to false, accessing a key that has nested values returns the entire structure @test
  • When configuration properly handles JSON structures, both simple strings and complex objects can be retrieved appropriately @test

Implementation

@generates

API

/**
 * Initializes the settings manager with translation resources and options.
 *
 * @param {Object} resources - The translation resources organized by language and namespace
 * @param {Object} options - Configuration options including language and ignoreJSONStructure setting
 * @returns {Promise<Object>} A promise that resolves to the initialized i18next instance
 */
async function initializeSettings(resources, options) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves a setting value using dot notation for nested access.
 * Can return strings, objects, or arrays depending on the translation structure.
 *
 * @param {string} key - The key to access, supporting dot notation for nested values
 * @param {Object} i18nextInstance - The initialized i18next instance
 * @returns {string|Object|Array} The setting value - can be a string, object, or array
 */
function getSetting(key, i18nextInstance) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves an entire settings object for a given key.
 *
 * @param {string} key - The key for the settings object
 * @param {Object} i18nextInstance - The initialized i18next instance
 * @returns {Object} The complete settings object
 */
function getSettingsObject(key, i18nextInstance) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves a settings array for a given key.
 *
 * @param {string} key - The key for the settings array
 * @param {Object} i18nextInstance - The initialized i18next instance
 * @returns {Array} The settings array
 */
function getSettingsArray(key, i18nextInstance) {
  // IMPLEMENTATION HERE
}

module.exports = {
  initializeSettings,
  getSetting,
  getSettingsObject,
  getSettingsArray
};

Dependencies { .dependencies }

i18next { .dependency }

Provides internationalization framework with JSON structure handling capabilities.

@satisfied-by

Version

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