Skip to content

NeoVim plugin enabling "go to definition" on language keys.

Notifications You must be signed in to change notification settings

MagerlinC/i18n.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

i18n lookup for NeoVim

This plugins provides a simply way to look up definitions for language keyed strings in your codebase. It does so by simple key look up in the configured translation files.

This is intended to be used with setups like i18next and accompanying localization/en.json, localization/da.json, etc. files.

Installation & Configuration

To set up the plugin, require the packager and supply a list of language configurations (filePath, keymap) to the setup function like so (example using Lazy):

return {
  "magerlinc/i18n.nvim",
  require('i18n').setup({
    {
      filePath = 'path/to/your/translations.json',
      keymap = 'your-keymap'
    },
    {
      filePath = 'path/to/your/other-translations.json',
      keymap = 'your-other-keymap'
    }
  })
}

For example, if you have a translation file en.json like this:

{
  "hello": "Hello",
}

And you set up the configuration like this:

require('i18n').setup({
  {
    filePath = 'path/to/your/en.json',
    keymap = '<leader>en'
  }
})

You can press <leader>en while your cursor is anywhere inside the string "hello" to look it up in the en.json file.

const greeting = t('hello'); // pressing <leader>en while your cursor is in the string will open the en.json file and go to the "hello" key

Creating translation entries

This plugin also supports passing a creation script and a keymap to call it:

require('i18n').setup({
  {
	creationKeymap = "<leader>gl",
	creationCmd = "yarn genlabel",
  }
})

This will allow you to press <leader>gl to run the given shell command, which can fx. run a script which generates the translation entries for you.

About

NeoVim plugin enabling "go to definition" on language keys.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages