tessl install tessl/npm-i18next-client@1.11.0DEPRECATED 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%
Build a translation manager that dynamically handles language switching, detection, and text direction for internationalized applications.
Your implementation should provide a translation manager with the following capabilities:
Initialize the translation system with English as the default language and Spanish as a fallback. The system should load translation resources from a simple in-memory resource store.
Implement functionality to switch between languages at runtime. When the language is changed, the system should:
Provide the ability to retrieve the currently active language code. This allows the application to know which language is being used at any given time.
Support retrieving the text direction (left-to-right or right-to-left) for the current language. This is essential for properly rendering languages like Arabic and Hebrew.
Provide a function to retrieve translated strings for the current language using translation keys.
@generates
/**
* Initialize the translation manager with configuration
* @param {Object} options - Configuration options
* @param {string} options.lng - Default language code
* @param {string} options.fallbackLng - Fallback language code
* @param {Object} options.resources - Translation resources by language
* @param {Function} callback - Callback function called after initialization
*/
function init(options, callback) {
// Implementation
}
/**
* Change the current language
* @param {string} lng - Language code to switch to
* @param {Function} callback - Callback function called after language change
*/
function changeLanguage(lng, callback) {
// Implementation
}
/**
* Get the current active language code
* @returns {string} Current language code
*/
function getCurrentLanguage() {
// Implementation
}
/**
* Get text direction for the current language
* @returns {string} 'ltr' for left-to-right, 'rtl' for right-to-left
*/
function getTextDirection() {
// Implementation
}
/**
* Translate a key using the current language
* @param {string} key - Translation key
* @returns {string} Translated string
*/
function translate(key) {
// Implementation
}
module.exports = {
init,
changeLanguage,
getCurrentLanguage,
getTextDirection,
translate
};Provides internationalization and translation management.
@satisfied-by