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

NEURS/gulp-transifex: Gulp Transifex

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

开源软件名称(OpenSource Name):

NEURS/gulp-transifex

开源软件地址(OpenSource Url):

https://github.com/NEURS/gulp-transifex

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-transifex

Gulp plugin for uploading resources and downloading translations in Transifex

Feel free to fork and improve

Usage

var options = {
    host: <String optional. Defaults to 'www.transifex.com'>,
    base_path: <String optional. Defaults to '/api/2/project/'>,
    user: <String required. Transifex username>,
    password: <String required. Transifex Password>,
    project: <String required. Transifex projects name>,
    local_path: <String optional. Local root path for the translations>,
    custom_language_codes:{
        <ISO 639-1 language code>: <custom language code>
    },
    use_custom_language_codes: <Boolean>,
    language_codes_as_objects: <Boolean>,
    translation_mode: <String optional. See 'https://docs.transifex.com/api/translations#downloading-and-uploading-translations'>
}

Using Custom Language Codes

Transifex uses ISO 639-1 to code languages. If you want to use your custom language code (another standard or just map es to Klingon) use the custom_language_codes option with use_custom_language_codes set to true.

###language_codes_as_objects By default the languages() method returns an array of strings with the language codes. If you specify custom_language_codes AND use_custom_language_codes is set to true, it will return an array of strings with your own custom codes. Additionally, if language_codes_as_objects is set to true it will return an array of object in the form:

[
    {
        <ISO 639-1 language code>: <custom language code>
    },
    ...
]

Uploading Resource files:

gulp-transifex will go file by file uploading them to the project as a resource Transifex will check if the file has changed and will store the changes

var transifex = require('gulp-transifex').createClient(options)
var gulp = require('gulp')

gulp.task('upstream', function(){
    return gulp.src('path/to/source/language/*')
        .pipe(transifex.pushResource())
})

Downloading translation files:

Similarly, for every resource file, gulp-transifex will check on the server for the languages and will start going to every file in each language and copy it in the local translation folder: options.local_path

var transifex = require('gulp-transifex').createClient(options)
var gulp = require('gulp')

gulp.task('downstream', function(){
    return gulp.src('path/to/source/language/*')
        .pipe(transifex.pullResource())
})

Chaining Tasks with gulp-transifex

Since this plugins makes remote requests you have to call it asynchronously if you need the translation files in next tasks, just return the stream:

var transifex = require('gulp-transifex').createClient(options)
var gulp = require('gulp')

gulp.task('downstream', function(){
    return gulp.src('path/to/source/language/*')
        .pipe(transifex.pullResource())
});

gulp.task('requireTransifexFiles', ['downstream'], function () {
    ...
});

Other methods exposed

There are other methods exposed that doesn't return streams but accepts callbacks:

###resources()

Gets an array of resources in the project

var transifex = require('gulp-transifex').createClient(options)

transifex.resources(function(data){
    ...
})

###languages()

Gets an array of language codes in the project

var transifex = require('gulp-transifex').createClient(options)

transifex.languages(function (data){
    ...
})

TODO

  • Add local modifications check. If there's no local modifications, don't bother check the file in transifex
  • Add updates check in translation files. If there ain't new translation why download the file.
  • Better division of concerns (Modularize further, separate transform function from stream declarations)



鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
yasinkocak/gulp-svn: SVN plugin for gulp发布时间:2022-06-21
下一篇:
robrich/gulp-match: Does a vinyl file match a condition?发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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