npm.io
1.4.0 • Published 6 years ago

gulp-i18n-localize

Licence
MIT
Version
1.4.0
Deps
6
Size
14 kB
Vulns
0
Weekly
0
Stars
9

gulp-i18n-localize Build Status

localization plugin for gulp

Install

$ npm install --save-dev gulp-i18n-localize

Usage

var gulp = require('gulp');
var i18n = require('gulp-i18n-localize');

gulp.task('default', function () {
	return gulp.src('src/index.html')
		.pipe(i18n({
			locales: ['en-US'],
			localeDir: './locales'
		}))
		.pipe(gulp.dest('dist'));
});

File structure

Create a localization folder locales for example that contains language subfolders. Translations are referenced against the folder name and key value in the file.

For example if you wanted to add spanish translations for animals you would create a .locales/es-US directory containing a animals.json file. The file would contain the translations below.

{
	"cat": "gato",
	"dog": {
		"name": "perro"
	}
}

You then could reference this by using ${{ animals.cat }}$ and ${{ animals.dog.name }}$ in your code.

API

i18n(options)
options
delimeters

Type: array Default: ['${{', '}}

Sets the delimeters to search assets files and replace with translated content. By default, it will match ${{ and $}}.

delimeter[0] | delimeter[1] | matches --- | --- | --- ${{ | }}$ | ${{ foo.bar }}$ !{ | }! | !{ foo.bar }! #{ | }# | #{ foo.bar }#


ignoreErrors

Type: boolean

Sets whether to ignore errors and prevent gulp from failing. This will still log errors to gulp.


localeDir

Type: array Required

Location of translation files. This is a required field.


locales

Type: array Default: ['en-US']

Locales to translate, should match localDir subfolders.


schema

Type: string Default: directory

Sets the schema to be used for naming translated assets.

schema output name
directory /en-US/index.html
suffix /index-en-US.html

License

MIT Filipe Araujo

]

Sets the delimeters to search assets files and replace with translated content. By default, it will match __INLINE_CODE_7__ and __INLINE_CODE_8__.

delimeter[0] | delimeter[1] | matches --- | --- | --- __INLINE_CODE_9__ | __INLINE_CODE_10__ | __INLINE_CODE_11__ __INLINE_CODE_12__ | __INLINE_CODE_13__ | __INLINE_CODE_14__ __INLINE_CODE_15__ | __INLINE_CODE_16__ | __INLINE_CODE_17__


ignoreErrors

Type: __INLINE_CODE_18__

Sets whether to ignore errors and prevent gulp from failing. This will still log errors to gulp.


localeDir

Type: __INLINE_CODE_19__ __INLINE_CODE_20__

Location of translation files. This is a required field.


locales

Type: __INLINE_CODE_21__ Default: __INLINE_CODE_22__

Locales to translate, should match __INLINE_CODE_23__ subfolders.


schema

Type: __INLINE_CODE_24__ Default: __INLINE_CODE_25__

Sets the schema to be used for naming translated assets.

schema output name
__INLINE_CODE_26__ __INLINE_CODE_27__
__INLINE_CODE_28__ __INLINE_CODE_29__

License

MIT Filipe Araujo

Keywords