kyu08 / js-i18n.nvim

a Neovim plugin for the JavaScript library i18next

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

日本語版 README (原文 | Original)

js-i18n.nvim

js-i18n.nvim is a Neovim plugin for the JavaScript library i18next.

Warning

This plugin is still under development and is optimized for the developer's use cases.

Installation

{
  "nabekou29/js-i18n.nvim",
  dependencies = {
    "neovim/nvim-lspconfig",
    "nvim-treesitter/nvim-treesitter",
    "nvim-lua/plenary.nvim",
  },
  event = { "BufReadPre", "BufNewFile" },
  opts = {}
}

Features

  • Display translations as virtual text
    • (Experimental) Hide keys and display only translations
  • Edit translations
  • Support for monorepos
  • LSP Support
    • Jump to definition of translation resources
    • Key completion
    • Display translations for each language on hover
  • Library Support
    • i18next
    • react-i18next
  • Translation resource formats
    • JSON
    • YAML

Advanced usage of i18next and react-i18next is not yet supported.

Usage

Commands

  • :I18nSetLang {lang} Sets the language. The set language is used for virtual text display and definition jumps.
  • :I18nVirtualTextEnable Enables the display of virtual text.
  • :I18nVirtualTextDisable Disables the display of virtual text.
  • :I18nVirtualTextToggle Toggles the display of virtual text.

Configuration

The default settings are as follows. For omitted parts, refer to config.lua.

{
  primary_language = {}, -- The default language to display (initial setting for displaying virtual text, etc.)
  translation_source = { "**/locales/*/translation.json" }, -- Pattern for translation resources
  detect_language = ..., -- Function to detect the language.
  key_separator = ".", -- Key separator
  virt_text = {
    enabled = true, -- Enable virtual text display
    conceal_key = false, -- Hide keys and display only translations
    fallback = false, -- Fallback if the selected virtual text cannot be displayed
    max_length = 0, -- Maximum length of virtual text. 0 means unlimited.
  },
}

About

a Neovim plugin for the JavaScript library i18next


Languages

Language:Lua 98.4%Language:JavaScript 1.6%