0.4.4 • Published 3 years ago

i18n-bin v0.4.4

Weekly downloads
45
License
-
Repository
-
Last release
3 years ago

i18n-bin

An i18n tool: extract translations to JSON/YAML file, and generate translation IDs automatically.

i18n extract app.ts --output=en.json

app.ts

 function t(descriptor: unknown) {
   return descriptor
 }

-t({ msg: 'msg #1' })
+t({ id: "H2ClXp", msg: 'msg #1' })

-t({ msg: 'msg #2', desc: 'desc #2' })
+t({ id: "YJreMb GQgx", msg: 'msg #2', desc: 'desc #2' })

 t({ id: 'id #3', desc: 'desc #3' })

en.json

 {
+  "H2ClXp": {
+    "msg": "msg #1"
+  },
+  "YJreMb GQgx": {
+    "msg": "msg #2",
+    "desc": "desc #2"
+  },
   "id #3": {
-    "msg": "msg #3"
+    "msg": "msg #3",
+    "desc": "desc #3"
   }
 }

Usage

CLI

$ i18n extract

  i18n extract <files..>

  Positionals:
    files  e.g. src/**/*.{ts,tsx}                               [array] [required]

  Options:
    --version             Show version number                            [boolean]
    --help                Show help                                      [boolean]
    --output              e.g. en.json                                    [string]
    --identifier.key                                      [string] [default: "id"]
    --identifier.pattern            [string] [default: "[msg:md5:6] [desc:md5:4]"]
    --template               [string] [default: "{"msg":"[msg]","desc":"[desc]"}"]

Gulp

const gulp = require('gulp')
const { extract } = require('i18n-bin')

gulp.task('extract', () => {
  return gulp
    .src('./src/**/*.{ts,tsx}')
    .pipe(extract())
    .pipe(gulp.dest('./src/i18n'))
})
0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago