Skip to content

Add support for deeply nested keys #97

Description

@erikvullings

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions