Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>kylin-i18n-helperNew to Visual Studio Code? Get it now.
kylin-i18n-helper

kylin-i18n-helper

oaooao

|
135 installs
| (1) | Free
i18n tool for kylin
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info
logo

Kylin-I18n-Helper

旨在提供一系列编辑器辅助功能用于提升 kylin 系统的国际化开发效率的同时,优化开发人员的开发体验

使用方式

VS Code 插件市场搜索 kylin-i18n-helper 安装

功能

  • 检测并提取代码中的中文文案

    • 提取为 通用文案 通用文案

    • 提取为 当前项目文案 当前项目文案

  • i18n 翻译组件 key 属性悬停和 JSON 源文件定位

    只支持当前项目文案的 JSON 定位和修改

    Sample

  • i18n 翻译组件 key 值输入错误提示

    Sample

  • 开发 / 预览模式切换

    Sample

要求

  • vscode 版本不低于 1.45.0
  • 项目里面应该提前配置好翻译组件 CommonTranslate、commonTranslate、Translate、translate, 下面是一个参考:
import * as React from "react";
import { observer } from "mobx-react";
import { languageStore } from "@/stores/language";
import { PortalService } from "@/services/portal";

interface IProps {
  i18n: string;
  data?: { [key: string]: any };
  component?: "span" | "div";
}

export const { translate } = languageStore;

@observer
export class Translate extends React.Component<IProps> {
  public render() {
    const { i18n, data, component = 'span' } = this.props;

    const text = translate(i18n, data);

    if (component === "span") {
      return <span data-i18n={i18n}>{text}</span>;
    }

    if (component === "div") {
      return <div data-i18n={i18n}>{text}</div>;
    }

    return <React.Fragment>{text}</React.Fragment>;
  }
}

interface ICommonTranslateProps {
  i18n: string;
  data?: { [key: string]: any };
  component?: "span" | "div";
}

export const CommonTranslate: React.FC<ICommonTranslateProps> = (props) => {
  const { Common } = PortalService.LanguageService;
  const { i18n, data, component = 'span' } = props;
  const text = Common.translate(i18n, data);

  if (component === "span") {
    return <span data-i18n={i18n}>{text}</span>;
  }

  if (component === "div") {
    return <div data-i18n={i18n}>{text}</div>;
  }

  return <React.Fragment>{text}</React.Fragment>;
};

export const commonTranslate = (i18n: string, data?: any) => {
  const { Common } = PortalService.LanguageService;

  return Common.translate(i18n, data);
};

Tips: 一个新的项目在使用 CommonTranslate 之前,需要确保在 server 里面做了 common-resource 的静态资源代理,详细文档请参考 麒麟国际化通用文案使用指南

设置

暂无

Known Issues

暂无

发布日志

0.0.1

Initial release of kylin-i18n-tool

0.2.0

新功能:

  • 添加zh-CN文件的codelens支持

0.3.0

新功能

  • 支持通过命令手动获取国际化通用文案

修复bug:

  • 通用文案不能匹配的问题

0.5.0

新功能

  • 检测到代码中含有中文文案的时候,在警告的同时提供快速基于改文案生成一个国际化key

0.12.0

新功能

  • 支持通过配置来开启和关闭该插件

🐣Enjoy!‍

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft