lazy.nvim
{
"BPplays/localize.nvim",
name = "localize.nvim",
config = function()
require('localize').setup({
-- language = { name = "ja_JP", spec = "utf8" },
})
end,
},
banks:
banks are groups of localizations by usage usually your plugin's name and who's making it
for example if you have a plugin my_cool_statusline
you might make a bank with name 'me/my_cool_statusline'
helpers:
helpers are optional parts added to the source words inside <> 'normal<vim mode>' would mean normal as in normal mode but the localized string should reflect the shortening without the helper,
for example 'normal<vim mode>' should not be localized to the language equal of 'normal mode' instead it should be just 'normal', the same kind of 'normal' you would use in saying 'normal mode'
start by using
local localize = require('localize')
you start by making a bank
local mybank = {}
mybank.ja_JP = {
['normal<vim mode>'] = 'ノーマル',
['insert<vim mode>'] = '挿入',
}
mybank = {
['_version'] = 1,
['ja_JP'] = mybank.ja_JP,
}
then you can add your bank by using
localize.set_bank('mybankname', mybank)
note: this function can throw an error
you must also use '_version' to specify what bank version to use, the only version currently is 1
you can use this to get a string or nil if it can't find anything
localize.get_string(string, bank_or_banks, lang, search_lower)
this will return the original string without the helper if it doesn't find anything
localize.get_string_orig(string, bank_or_banks, lang, search_lower)
- string - is the string source
- bank_or_banks - bank or banks to use - can be one bank name or multiple
- lang - the language to use - defaults to the users language
- search_lower - search_lower whether or not to also search a lowercase version of the source string
the most basic use case would be:
localize.get_string_orig('normal<vim mode>')
but if you want to specify the bank you can do
localize.get_string_orig('normal<vim mode>', 'mybankname')
there are also reserved bank names ['global', 'builtin', 'internal']