-
Notifications
You must be signed in to change notification settings - Fork 23
/
gulpfile.coffee
137 lines (124 loc) · 3.21 KB
/
gulpfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
gulp = require 'gulp'
i18n = require './lib/index'
coffee = require 'gulp-coffee'
#
# Writes the coffeescript to javascript
#
gulp.task 'compile', ->
gulp.src('src/**/*.coffee')
.pipe coffee()
.pipe gulp.dest('lib')
#
# Demonstrates a basic execution
#
gulp.task 'normal', ->
gulp.src('example/src/**/index.src.html')
.pipe i18n
langDir: 'example/src/lang'
trace: true
.pipe gulp.dest('example/dest')
#
# Demonstrates writing the translation of a single language iniline,
# rather than creating language-specific files
#
gulp.task 'inline', ->
gulp.src('example/src/**/index.src.html')
.pipe i18n
langDir: 'example/src/lang'
inline: 'en'
.pipe gulp.dest('example/dest/inline')
#
# Demonstrates creating language specific subdirectories, rather than
# creating suffixed files
#
gulp.task 'dirs', ->
gulp.src('example/src/**/index.src.html')
.pipe i18n
createLangDirs: true
langDir: 'example/src/lang'
defaultLang: 'zh-cn'
trace: true
.pipe gulp.dest('example/dest/dirs')
#
# Demonstrates what happens when a key is missing
#
gulp.task 'failure', ->
gulp.src('example/src/**/failure.src.html')
.pipe i18n
langDir: 'example/src/lang'
trace: true
failOnMissing: false
.pipe gulp.dest('example/dest/failure')
#
# Demonstrates what happens when a key is missing
#
gulp.task 'fallback', ->
gulp.src('example/src/**/index.src.html')
.pipe i18n
langDir: 'example/src/fallback'
trace: true
fallback: 'en'
.pipe gulp.dest('example/dest/fallback')
#
# Demonstrates escape
#
gulp.task 'escape', ->
gulp.src('example/src/**/escape.src.html')
.pipe i18n
escapeQuotes: true
langDir: 'example/src/escape'
trace: true
.pipe gulp.dest('example/dest/escape')
#
# Demonstrates commonjs
#
gulp.task 'commonjs', ->
gulp.src('example/src/**/index.src.html')
.pipe i18n
langDir: 'example/src/commonjs'
trace: true
.pipe gulp.dest('example/dest/commonjs')
#
# Demonstrates filename-i18n
#
gulp.task 'filename-i18n', ->
gulp.src('example/src/**/${{common.title}}$.src.html')
.pipe i18n
langDir: 'example/src/lang'
filenameI18n: true
trace: true
.pipe gulp.dest('example/dest/filename-i18n')
#
# Demonstrates jsfile
#
gulp.task 'jsfile', ->
gulp.src('example/src/index.js')
.pipe i18n
langDir: 'example/src/lang'
trace: true
.pipe gulp.dest('example/dest')
#
# Demonstrates resolve-reference
#
gulp.task 'jsfile', ->
gulp.src('example/src/resolve-reference/**/*.js')
.pipe i18n.resolveReference
langDir: 'example/src/resolve-reference'
.pipe gulp.dest('example/dest/resolve-reference')
#
# Demonstrates mustache renderEngine
#
gulp.task 'mustache', ->
gulp.src('example/src/mustache.src.html')
.pipe i18n
langDir: 'example/src/mustache'
renderEngine: 'mustache'
trace: true
extendDefination: (info) ->
{extend: Object.keys(info).join(' ')}
.pipe gulp.dest('example/dest')
#
# Calling `gulp` will compile
#
gulp.task 'default', gulp.series ['compile']
gulp.task 'example', gulp.series ['normal', 'inline', 'dirs', 'failure', 'fallback', 'escape', 'commonjs', 'filename-i18n', 'jsfile', 'mustache']