Skip to main content
Plugins can provide translations for their user-facing strings, making them accessible to international users. Fresh provides a simple i18n system based on JSON translation files.

Creating Translation Files

Create a .i18n.json file alongside your plugin with the same base name:

Translation File Structure

The translation file uses a simple two-level structure: locale → key → translation.

Key Conventions

Organize your translation keys using prefixes:

cmd.*

Command names and descriptions

status.*

Status bar messages

prompt.*

Prompt labels

error.*

Error messages

Interpolation

Use %{variable} syntax for variable interpolation:

Using Translations

Translating Status Messages

Use editor.t() to translate status messages:
The editor.t() method is available through the pluginTranslate API function.

Translating Command Registration

Use % prefix for command names and descriptions to enable automatic translation:

Translating Prompt Labels

Translation API

pluginTranslate

Translate a string for a plugin using the current locale.
string
required
Name of the plugin (matches the .ts file name)
string
required
Translation key (e.g., “status.ready”)
Record<string, unknown>
required
Variables for interpolation
string
Translated string with variables interpolated
Example:

getCurrentLocale

Get the currently active locale.
string
Current locale code (e.g., “en”, “es”, “fr”)
Example:

Translation Loading

Translations are automatically loaded when your plugin loads. If the user’s locale isn’t available in your translation file, English (en) is used as a fallback.

Fallback Chain

  1. User’s configured locale (e.g., es)
  2. English (en)
  3. Original key string
Example:

Complete Example

Plugin File (git_grep.ts)

Translation File (git_grep.i18n.json)

Best Practices

English (en) is the fallback locale. All plugins should include English translations.
Follow the convention of prefixing keys by category: cmd.*, status.*, prompt.*, etc.
Status bar messages and command names should be short and clear in all languages.
Test your plugin with different locale settings to ensure translations display correctly.
Always convert numbers to strings for interpolation:

Example Plugins with i18n

See these plugins for complete examples:
  • plugins/git_grep.ts + plugins/git_grep.i18n.json
  • plugins/git_find_file.ts + plugins/git_find_file.i18n.json
  • plugins/git_gutter.ts + plugins/git_gutter.i18n.json