• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

filaraujo/gulp-i18n-localize: localization plugin for gulp

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

filaraujo/gulp-i18n-localize

开源软件地址(OpenSource Url):

https://github.com/filaraujo/gulp-i18n-localize

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap