在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):webyom/gulp-html-i18n开源软件地址(OpenSource Url):https://github.com/webyom/gulp-html-i18n开源编程语言(OpenSource Language):CoffeeScript 45.2%开源软件介绍(OpenSource Introduction):gulp-html-i18nInternationalize your HTML files with gulp! Language Definition Files
JSGiven the following in a file named: AMDdefine({
heading: "Welcome!",
footer: "Copyright 2015"
}); CommonJSmodule.exports = {
heading: "Welcome!",
footer: "Copyright 2015"
};
JSONGiven the following in a file named: {
"heading": "Welcome!",
"footer": "Copyright 2015"
}
YAMLGiven the following in a file named: heading: Welcome!
footer: Copyright 2015
HTML MarkupTo use either of the examples from above, replace the text in your HTML files
with a formatted tag:
Example: index.htmlInitial: <html>
<body>
<h1>${{ index.heading }}$</h1>
<div>
<!-- Website content -->
</div>
<div>${{ index.footer }}$</div>
<body>
</html> Output: <html>
<body>
<h1>Welcome!</h1>
<div>
<!-- Website content -->
</div>
<div>Copyright 2015</div>
<body>
</html> Render Engine
RegexThis is the default and is used either with the langRegExp (the most flexible) or delimiters (easier) MustacheProvides additional support for things like loops and conditionals. (for full mustache documentation) You must used delimiters for mustache, you cannot use langRegExp option en/index.yaml [ Yaml is useful for multiline strings ] home:
paragraphs:
- >
First paragraph contents
put together in multiple lines
- >
Second paragraph
also in multiple lines
- Third Paragraph gulpfile.js i18n({
langDir: './lang',
renderEngine: 'mustache'
}) index.html <h1>Welcome</h1>
${{# home.paragraphs }}$
<p>${{ . }}$</p>
${{/ home.paragraphs }}$ Will produce : index-en.html <h1>Welcome</h1>
<p>First paragraph contents put together in multiple lines</p>
<p>Second paragraph also in multiple lines</p>
<p>Third Paragraph</p> Gulp UsageThe following task: gulp.task('build:localize', function() {
var dest = './public';
var index = './index.html';
return gulp.src(index)
.pipe(i18n({
langDir: './lang',
trace: true
}))
.pipe(gulp.dest(dest));
}); will compile Options
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论