Giter Club home page Giter Club logo

atrans's Introduction

Atrans

Atrans(Android xml translate) Android项目layout drawable resources xml资源转Harmony对应json 或xml资源文件

IDEA插件

IDEA插件下载安装

如何下载使用

  1. 下载 atrans.zip, 解压缩保存
  2. 配置环境变量
    为了支持在cmd窗口下从任意路径访问atrans.bat, 需要将atrans.bat所在目录添加到环境变量path中.
    1. 新建环境变量key: atranspath, value: atrans.bat所在目录
    2. %atranspath%添加到环境变量path中
atranspath='atrans.bat所在目录'
path=%atranspath%...;

添加环境变量
3. 打开命令行cmd窗口, 键入 trans /?, 如提示使用使用帮助指南则表示配置成功, 否则需要检查变量配置是否正确 添加环境变量

解析器配置文件介绍

atrans模块

  • reply转换器
    reply_parse_config.xml字段说明
<rule>
    <!--  命名空间name为android的将被替换为ohos -->
    <reply name="namespacePrefix" src="android">ohos</reply>
  <!--  命名空间uri部分为heep://xxxd的将被替换为http://schemas.huawei.com/res/ohos -->
    <reply name="namespaceURI" src="http://schemas.android.com/apk/res/android" mode="word_all">
        http://schemas.huawei.com/res/ohos
    </reply>
    <!-- ElementName为View的将被替换为Component -->
    <reply name="elementName" src="View" mode="word_all">Component</reply>
    <reply name="attributeName" src="gravity" mode="word_all">alignment</reply>
    <!-- ElementName包含dp的部分将被替换为vp,且不区分大小写 -->
    <reply name="attributeValue" src="dp" ignoreCase="true" mode="contains_match">vp</reply>
    ...
</rule>

name属性值对应xml元素内容 replyName字段意义

mode字段意义

属性值 属性意义
word_all 单词对比, 完整替换
contains_match 包含对比, 包含替换
contains_all 包含对比, 完整替换
  • json转换器
    json_parse_config.xml
<parser>
 <!--  ElementName为dimen的将解析为json对象, 在嵌套key为"float"的对象中输出  -->
 <parse name="dimen" jsonKey="float" type="object">
   <!--  属性值dp的将被替换vp, 且不区分大小写  -->
     <reply name="attributeValue" src="dp" ignoreCase="true" mode="contains_match">vp</reply>
 </parse>
 <!--  ElementName为array的将解析为json数组, 在嵌套key为"strarray"的对象中输出  -->
 <parse name="array" jsonKey="strarray" type="array" />
</parser>

translate作为独立的功能模块, 你可以基于此library实现idea插件

License

Apache 2.0, See the LICENSE file for details.

atrans's People

Contributors

yuxiangxin avatar

Stargazers

Jooyer avatar Janky avatar zhangjunpu avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

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.