You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

技术求助:如何入门i18n-ally?翻译自制VSCode扩展失效且无get started指引

Hey there, let's tackle your issues step by step—whether it's getting started with i18n-ally or fixing those unresponsive translation actions for your VS Code extension.

1. Quick Start with i18n-ally

Since you couldn't find the get started guide, here's a condensed, practical walkthrough to get you going:

  • Install the extension: Search for i18n-ally in VS Code's Extensions panel and hit install.
  • Set up your config: Create a .vscode/i18n-ally-custom.json (or edit workspace settings) to define your translation structure. At minimum, add these core settings:
    {
      "localesPaths": ["src/locales"],
      "primaryLocale": "en",
      "fallbackLocale": "en",
      "enabledParsers": ["json", "ts", "py"]
    }
    
  • Initialize translation files: Create a folder (like src/locales) with your primary locale file (e.g., en.json) and add initial key-value pairs:
    {
      "greeting": "Hello World",
      "extension.name": "My Custom Extension"
    }
    
  • Start translating: Right-click on a string in your code, select i18n-ally: Extract to locale key, and follow prompts to add it to your locale files.
2. Fixing "No Actions Take Effect" Issue

If none of your translation operations work, try these troubleshooting steps:

  • Verify config correctness: Double-check that enabledParsers includes json, ts, and py in your i18n-ally settings. Also confirm localesPaths points to the actual folder where your translation files live.
  • Check file associations: Make sure VS Code recognizes your files correctly (e.g., .ts files are marked as TypeScript, .py as Python). Incorrect file types can prevent i18n-ally from parsing them.
  • Validate translation syntax: Ensure your locale files have valid syntax (no missing commas in JSON, no typos in TypeScript/Python dictionaries). A single syntax error can break the entire setup.
  • Restart VS Code and extension: Sometimes a fresh start fixes glitches—try reloading the window (Ctrl+Shift+P → Reload Window) or disabling/enabling i18n-ally again.
3. Handling Different File Types

Here's how to work with your specific file types:

  • JSON: i18n-ally natively supports JSON locale files. For your extension's package.json, use %extension.name% to reference translation keys—i18n-ally will pick them up if your config is set correctly.
  • TypeScript: Use a translation function (like t('greeting')) in your code. Configure the translationFunction setting to let i18n-ally detect these calls:
    "translationFunction": ["t", "$t", "i18n.t"]
    
    Make sure your TypeScript code imports the translation function from your i18n setup (e.g., using vscode-nls for VS Code extensions).
  • Python: If your extension has Python components, use gettext or libraries like python-i18n. i18n-ally can parse .po/.mo files or Python dictionaries—just add po or py to enabledParsers and point localesPaths to your Python translation directory.

内容的提问来源于stack exchange,提问作者Frank4466

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 16:52:34