PrefaceThe biggest pain point with existing i18n plugins on the market is that they cannot cover the internationalization needs of every project. Take our company’s project as an example: the requirement is to automatically generate a key based on the semantic meaning of a text entry and write it into the corresponding i18n file and code, making internationalization development as simple as regular development. Although the requirement sounds simple, a suitable plugin was hard to find. i18n Ally focuses more on translation and management, and does not support automatic key generation—you have to input keys manually; Du I18N generates keys as hash values, which do not meet my needs, and cannot directly write to i18n files (manual synchronization is required). Additionally, both plugins impose strict restrictions on the project tech stack and have limited support for PHP. I18n Fast is an i18n generation plugin that emphasizes customizability. The plugin itself does not implement specific functionality; instead, it leverages a hook mechanism that allows users to implement their own logic. The plugin simply connects the hooks to make the process work. In short, by increasing configuration overhead and enabling the dynamic execution of external code, it sacrifices some out-of-the-box ease for generality and flexibility, thereby meeting the internationalization needs of a wider range of projects. If other i18n plugins cannot meet your requirements and you're willing to invest some time understanding and writing hook files, then I18n Fast is your ideal choice. Features
Quick StartSearch for I18n Fast in the VS Code Marketplace and click Install, or download the corresponding version from releases. In VS Code, open the Command Palette with After installing the plugin, you need to complete the plugin configuration and hook files. With a well-configured setup, you should see i18n feedback when previewing your code. Try using the i18n-fast.convert or i18n-fast.paste command to verify your implementation! FlowchartConfigurationPlugin Configuration
HookA hook file is a JavaScript file that exports hook methods for the plugin to call (see the flowchart for execution timing). The hook runs in Node.js, adheres to the CommonJS standard, supports asynchronous functions (async/await), and can The hook file is located based on the config.hookFilePattern, defaulting to Feel free to submit an issue to share your hook files (example: https://github.com/lvboda/vscode-i18n-fast/issues/21) so others can refer to and reuse your code.
ContextThe context object shared with hooks is passed as the first argument and includes:
The above lists the public properties available to every hook. There are additional properties (such as hook.matchExecuted at the very start of the i18n-fast.convert command, this hook customizes how text in the current document is matched and returns the matching results. Note the priority: if the i18n-fast.paste command is invoked or text is selected, In this example, hook.convertExecuted immediately after In this example, hook.writeExecuted after In this example, hook.collectI18nTriggered during initialization, configuration, or when i18n files change, this hook collects i18n data. In this example, hook.matchI18nTriggered while browsing code, this hook filters matched i18n keys or customizes i18n feedback/jump/hoverMessage functionality, with matching based on the i18nKey by default. In this example, Commandsi18n-fast.convertThe convert command transforms matched text into the i18n format. Shortcut: Execution Flow:
i18n-fast.pasteThe paste command converts text from the clipboard into the i18n format and pastes it. Shortcut: Execution Flow:
i18n-fast.undoThe undo command undoes all file write operations performed in this session. Shortcut:
FAQI still don't know how to configure it after reading the documentation. What should I do?Each project in the test folder is a complete usage example that you can refer to directly. If you're still confused, please submit an issue. I don't want to write code. Is there another way to use it directly?Check the issues under the hook example label for some hook examples you can refer to or use directly. Is executing dynamic code a security risk?I18n Fast is a fully standalone application. In theory, as long as you ensure that the hook code you write is secure, there is no security risk. LicenseCopyright (c) 2025 - Boda Lü |