Giter Club home page Giter Club logo

ati18n's Introduction

Documentation Status

基本用法

Usage: cli.py [OPTIONS] PATH

  Console script for ati18n.

  用来检查国际化是否有问题或可疑点的工具,支持Java应用、Vue应用、Flask应用中的多语言功能,检查其中是否有些可能的问题点,方便研发人员快速解决问题。

Arguments:
  PATH    应用路径  [required]

Options:
  -t, --type [Java|Vue|Flask]     specify the app type. 指定应用类型  [default:
                                  Java]
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  --help                          Show this message and exit.

Feature 特性

  • 基于规则的检查模式,方便扩充
  • 可以检查三个范围可能的问题,翻译文件级别、单个翻译项级别、多个关联翻译项级别
  • 统一的规则定义、错误信息定义,方便使用
  • 基于python实现,可跨平台运行
  • 支持检查多种应用检查

Design Notes 概要设计

使用方法说明

本工具的目标是更实用为多语言类应用提供支持,提升这方面的效率。主要的使用方法有三类:

  • 命令行调用直接检查,直观的输出结果
  • 命令行调用,输出数据结果文件,方便不同工具之间的衔接
  • 可以集成到各类IDE中,方便在IDE中交互式使用

结果数据

在第二种方式中,ati18n会根据检查结果生成一个检查结果数据文件,实际的数据结果文件是检查信息数据结构的一个数组,举例如下:

{
    "tools": "ati18n",
    "version": "0.1.0",
    "app_path": "/xxx/xxx",
    "app_type": "Java",
    "datetime": "1990-01-01 12:12:12",
    "result": [
        {
            "No": "1001",
            "Level": "错误",
            "Scope": "整体翻译",
            "Name": "翻译条目数不匹配",
            "Data": {
                "type": "file",
                "file_path": "/xxx.properties"
            },
            "Comment": ""
        },
        {
            "No": "1002",
            "Level": "错误",
            "Scope": "整体翻译",
            "Name": "文件名指定的语言种类和文件内容不匹配",
            "Data": {
                "type": "file",
                "file_path": "/xxx.properties"
            },
            "Comment": ""
        },
        {
            "No": "2001",
            "Level": "警告",
            "Scope": "单个翻译项",
            "Name": "翻译项和指定的语言类型不匹配",
            "Data": {
                "type": "item",
                "key_name": "xxxx",
                "key_value": "xxxx",
                "lang_code": "zh_CN",
                "info": "翻译项全是英文,没有中文字符",
                "file_path": "/xxx.properties"
            },
            "Comment": ""
        }
    ]
}

检查信息数据结构

针对应用的多语言检查,会发现相应的问题,这里定义一下返回问题的可能情况

  • 级别:错误、警告、提示
  • 范围:整体翻译,单个翻译项,多个翻译项
编号 No 级别 Level 范围 Scope 错误名称 Name 详细信息 Data 备注 Comment
1001 错误 整体翻译 翻译条目数不匹配 检查的数据文件和相关信息
1002 错误 整体翻译 文件名指定的语言种类和文件内容不匹配 检查的数据文件和相关信息
2001 警告/错误 单个翻译项 翻译项和指定的语言类型不匹配 检查的数据项和相关信息
2002 错误 单个翻译项 翻译项在 item 级别为空 检查的数据项和相关信息
2003 错误 单个翻译项 源代码中有的 item 没有对应的翻译 检查的数据项和相关信息
3001 警告/错误 多个翻译项 多个相同 key ,但是 value 不一致 检查的数据项和关联所有翻译项信息
3002 警告/错误 多个翻译项 同一个语言的value,对应的其他语言翻译不一样 检查的数据项和关联所有翻译项信息

检查规则汇总

在应用中的多语言检查,会有各种规则,这里列出来可能适合的规则

规则编号 范围 规则名称 关联检查信息 备注
G1001 整体翻译 检查翻译文件中翻译项数量是否匹配 1001
G1002 整体翻译 翻译文件语言种类和文件名称不匹配 1002
G2001 单个翻译条目 翻译文件语言种类和待翻译项名称不匹配 2001
G2002 单个翻译条目 检查 item 级别的空规则 2002
G2003 单个翻译条目 源代码中有的 item,但是没有对应的翻译 2003
G3001 多个翻译条目 多个相同 key ,但是 value 不一致 3001
G3002 多个翻译条目 同一个语言的value,对应的其他语言翻译不一样 3002

Reference

ati18n's People

Contributors

mr0g avatar painterg avatar renweibo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zslhg903

ati18n's Issues

Task: Add first use case/ 增加第一个用例

Use Case 用例

User can use this tool to check language file for i18n or language related check.

用户可以使用这个工具对语言翻译文件做国际化或者翻译相关的检查。

Support Check j2ee i18n properties for item number

Support Check j2ee i18n properties for item number.

支持第一个规则:

  • 检查j2ee国际化里,不同语言的条目数,默认拿英文做基础,举例来说,如果英文的国际化条目数是10条,但是中文的条目数多于或少于10条,即本规则检查出一条错误信息。
  • 遍历语言文件,汇总出语言条目数不匹配的有多少条

这里参考基本的错误信息规范,需要定义清楚。

Support Dockerfile 支持Dockerfile

项目已经有了开发用的dockerfile,同时是搭配vscode 的remote模式

还需要一个用户的docker image,方便大家使用,这个image会放到docker hub上

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.