forked from musterknabe/translate.js
-
Notifications
You must be signed in to change notification settings - Fork 7
Add support for deeply nested keys #97
Copy link
Copy link
Open
Description
Hi Stephan,
I'm using your great library in many of my projects, as it offers a very elegant and practical solution to adding translations to my project. However, sometimes it is practical to organise keys of a component in a nested structure, but this is only partially possible: one subkey is allowed, or alternatively, a property for pluralisation, but not both. Also many AI code editors (Claude, Gemini, CodeWiki) expect more deeply nested keys, using dot notation, e.g.
var messages = {
EDITOR: {
NODE: {
NAME: 'Name',
DESCRIPTION: 'Description',
ICON: 'Icon',
},
EDGE: {
DIRECTION: 'Direction',
EFFECT: 'Effect',
},
}
};
var t = translate(messages);
// Accessing a deeply nested key
console.log(t('EDITOR.NODE.NAME')); // This is illustrative; the actual call might vary based on how you pass multiple subkeys.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels