Skip to content

AST-based internationalization syntax extraction and compilation assistant tool

Notifications You must be signed in to change notification settings

sogud/react-intl-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-intl-parse 基于AST 国际化语法提取与编译辅助工具

配置示例

 module.exports = {
  additionalFunctionNames: ['t'],
  // 提取t函数的ast逻辑
  additionalFunctionAst: (node) => {
    const properties = node.arguments;
    if (properties?.[0]?.value) {
      const params = {
        id: properties?.[0].value,
        defaultMessage: properties?.[1]?.value || properties?.[0]?.value,
      };
      return params;
    }
  },
  extract: {
    input: './src',
    output: './src/locales',
    includes: ['.ts', '.tsx', '.js', '.jsx'],
    excludes: ['.umi', 'typings.d.ts', 'API.d.ts'],
    format: 'ts',
    languages: ['zh-CN', 'en-US'],
  },
  compile: {
    input: './languages.xlsx',
    output: './locales',
    format: 'ts',
    languages: ['zh-CN', 'en-US'],
  },
};

使用示例

react-intl-parse extract

react-intl-parse compile

About

AST-based internationalization syntax extraction and compilation assistant tool

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published