All Projects → sibelius → Ast I18n

sibelius / Ast I18n

Licence: mit
Easily migrate your existing React codebase to use i18n

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ast I18n

I18nize React
Internationalize react apps within a lunch break
Stars: ✭ 389 (+201.55%)
Mutual labels:  ast, i18n
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (+4.65%)
Mutual labels:  i18n, ast
I18n Ally
🌍 All in one i18n extension for VS Code
Stars: ✭ 1,931 (+1396.9%)
Mutual labels:  i18n
Play Jsmessages
Library to compute localized messages of your Play application on client side
Stars: ✭ 125 (-3.1%)
Mutual labels:  i18n
Asteval
minimalistic evaluator of python expression using ast module
Stars: ✭ 116 (-10.08%)
Mutual labels:  ast
Traduora
Ever® Traduora - Open-Source Translation Management Platform
Stars: ✭ 1,580 (+1124.81%)
Mutual labels:  i18n
React I18nify
Simple i18n translation and localization components and helpers for React.
Stars: ✭ 123 (-4.65%)
Mutual labels:  i18n
Cgen
C/C++ source generation from an AST
Stars: ✭ 107 (-17.05%)
Mutual labels:  ast
Go I18n
Translate your Go program into multiple languages.
Stars: ✭ 1,834 (+1321.71%)
Mutual labels:  i18n
Milkomeda
Spring extend componets which build from experience of bussiness, let developers to develop with Spring Boot as fast as possible.(基于Spring生态打造的一系列来自业务上的快速开发模块集合。)
Stars: ✭ 117 (-9.3%)
Mutual labels:  i18n
D2 Admin
An elegant dashboard
Stars: ✭ 11,012 (+8436.43%)
Mutual labels:  i18n
Nlcst
Natural Language Concrete Syntax Tree format
Stars: ✭ 116 (-10.08%)
Mutual labels:  ast
Phabricator zh hans
Phabricator zh-Hans Translation & Tools.
Stars: ✭ 113 (-12.4%)
Mutual labels:  i18n
Vue I18n Extract
Manage vue-i18n localization with static analysis
Stars: ✭ 123 (-4.65%)
Mutual labels:  i18n
Yaep
Yet Another Earley Parser
Stars: ✭ 110 (-14.73%)
Mutual labels:  ast
Phplrt
PHP Language Recognition Tool
Stars: ✭ 127 (-1.55%)
Mutual labels:  ast
Pseudo Localization
Dynamic pseudo-localization in the browser and nodejs
Stars: ✭ 109 (-15.5%)
Mutual labels:  i18n
Ast
Generic AST parsing library for kotlin multiplatform
Stars: ✭ 113 (-12.4%)
Mutual labels:  ast
Math Engine
Mathematical expression parsing and calculation engine library. 数学表达式解析计算引擎库
Stars: ✭ 123 (-4.65%)
Mutual labels:  ast
Talkr
Talkr is a super small i18n provider for React applications. It supports Typescript, has 0 dependencies, and is very easy to use.
Stars: ✭ 129 (+0%)
Mutual labels:  i18n

AST i18n Build Status

The objective of this tool is to make easy to migrate an existing codebase to use i18n

How it works

  • it gets a list of files from the command line
  • it runs a babel plugin transform to find all string inside JSXText
  • it generates a stable key for the extracted strings
  • it generates i18n files format based on this map
  • it modify your existing code to use i18n library of your preference

Example

Before this transform

import React from 'react';

const Simple = () => (
  <span>My simple text</span>
);

After this transform

import React from 'react';
import { withTranslation } from 'react-i18next'

const Simple = ({ t }) => (
  <span>{t('my_simple_text')}</span>
);

Usage of string extractor

yarn start --src=myapp/src
  • It will generate a resource.jsx file, like the below:
export default {
  translation: {
   'ok': `ok`,
   'cancelar': `cancelar`,
   'continuar': `continuar`,
   'salvar': `salvar`,
   'endereco': `endereço:`,
   'troca_de_senha': `troca de senha`,
   'dados_pessoais': `dados pessoais`,
   [key]: 'value',
  }
}

How to use resource with react-i18next?

  • rename resource.tsx to your main language, like en.ts
  • create other resource languages based on the generated one
import en from './en';

i18n.use(LanguageDetector).init({
  resources: {
    en,
  },
  fallbackLng: 'ptBR',
  debug: false,

  interpolation: {
    escapeValue: false, // not needed for react!!
    formatSeparator: ',',
  },

  react: {
    wait: true,
  },
});

Usage of i18n codemod

npm i -g jscodeshift

jscodeshift -t src/i18nTransfomerCodemod.ts PATH_TO_FILES

How to customize blacklist

Use ast.config.js to customize blacklist for jsx attribute name and call expression calle

module.exports = {
  blackListJsxAttributeName: [
    'type',
    'id',
    'name',
    'children',
    'labelKey',
    'valueKey',
    'labelValue',
    'className',
    'color',
    'key',
    'size',
    'charSet',
    'content',
  ],
  blackListCallExpressionCalle: [
    't',
    '_interopRequireDefault',
    'require',
    'routeTo',
    'format',
    'importScripts',
    'buildPath',
    'createLoadable',
    'import',
    'setFieldValue',
  ],
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].