add english version

This commit is contained in:
kekee000
2015-05-29 17:05:15 +08:00
parent 48fc7be9a4
commit 4e2c0f1c46
49 changed files with 592 additions and 493 deletions

50
build/build-index.js Normal file
View File

@@ -0,0 +1,50 @@
/**
* @file 编译首页文件,编译为中文版和英文版
* @author mengke01(kekee000@gmail.com)
*/
var fs = require('fs');
var path = require('path');
/**
* 字符串格式化,支持如 ${xxx.xxx} 的语法
* @param {string} source 模板字符串
* @param {Object} data 数据
* @return {string} 格式化后字符串
*/
function format(source, data) {
return source.replace(/\$\{([\w.]+)\}/g, function ($0, $1) {
var ref = $1.split('.');
var refObject = data;
var level;
while (refObject != null && (level = ref.shift())) {
refObject = refObject[level];
}
return refObject != null ? refObject : '';
});
}
/**
* 入口
*/
function main(version) {
var baseDir = path.dirname(__dirname);
var tpl = String(fs.readFileSync(baseDir + '/index.tpl'));
tpl = tpl.replace(/\s+/g, ' ').replace('./src', './' + version);
var i18n = {};
i18n.lang = require('./i18n.zh-cn');
var fileContent = format(tpl, i18n);
fs.writeFileSync(baseDir + '/index.html', fileContent);
i18n.lang = require('./i18n.en-us');
fileContent = format(tpl, i18n);
fs.writeFileSync(baseDir + '/index-en.html', fileContent);
}
main.apply(null, process.argv.slice(2));

43
build/i18n.en-us.js Normal file
View File

@@ -0,0 +1,43 @@
module.exports = exports = {
lang: 'en-us',
newglyph: 'New Glyph',
undo: 'Undo',
redo: 'Redo',
import: 'Import',
import_svg: 'Import svg',
import_svg_title: 'Import svg font or svg file',
import_pic: 'Import Image',
import_pic_title: 'Import image with glyph',
import_font: 'Import Font',
import_font_title: 'Import ttf,woff,eot,otf font',
export_ttf: 'Export ttf',
export_woff: 'Export woff',
export_zip: 'Export zip file, including ttf,woff,eot,svg font and examples.',
save_proj: 'Save Project',
onlinefont: 'Online Font',
fonturl: 'Font URL',
tool: 'Tools',
gen_glyph_name: 'Generate Glyph Name',
clear_glyph_name: 'Clear Glyph Name',
optimize_glyph: 'Optimize Glyph',
compound2simple: 'Composite Glyph to Simple Glyph',
preview: 'Preview',
preview_ttf: 'ttf Font',
preview_woff: 'woff Font',
preview_svg: 'svg Font(Only safari)',
preview_eot: 'eot Font(Only IE)',
new_font: 'New',
new_font_title: 'new font',
open_font: 'Open',
open_font_title: 'Open ttf,woff,eot,otf format font file',
project_list: 'Project List',
close_editor: 'Click or press `F2` to close glyph editor',
metrics: 'Metrics',
editor_setting: 'Editor Setting',
import_and_export: 'Import and Export',
setting: 'Setting',
help: 'Help',
confirm: 'Confirm',
cancel: 'Cancel',
fontinfo: 'Font Info'
};

43
build/i18n.zh-cn.js Normal file
View File

@@ -0,0 +1,43 @@
module.exports = exports = {
lang: 'zh-cn',
newglyph: '新字形',
undo: '撤销',
redo: '重做',
import: '导入',
import_svg: '导入svg',
import_svg_title: '导入svg格式字体文件',
import_pic: '导入图片',
import_pic_title: '导入包含字形的图片',
import_font: '导入字体文件',
import_font_title: '导入ttf,woff,eot,otf格式字体文件',
export_ttf: '导出ttf',
export_woff: '导出woff',
export_zip: '导出zip,包含ttf,woff,eot,svg等格式字体和icon示例',
save_proj: '保存项目',
onlinefont: '线上字体',
fonturl: '字体URL',
tool: '工具',
gen_glyph_name: '生成字形名称',
clear_glyph_name: '清除字形名称',
optimize_glyph: '优化字体',
compound2simple: '复合字形转简单字形',
preview: '预览',
preview_ttf: 'ttf字体',
preview_woff: 'woff字体',
preview_svg: 'svg字体(仅safari)',
preview_eot: 'eot字体(仅IE)',
new_font: '新建',
new_font_title: '新建ttf字体文件',
open_font: '打开',
open_font_title: '打开ttf,woff,eot,otf格式字体文件',
project_list: '项目列表',
close_editor: '点击或者按`F2`键关闭编辑器',
metrics: '字体度量',
editor_setting: '编辑器设置',
import_and_export: '导入和导出',
setting: '设置',
help: '帮助',
confirm: '确定',
cancel: '取消',
fontinfo: '字体信息'
};