V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Dive into HTML5
http://diveintohtml5.org/
FuGardenia
V2EX  ›  HTML

纯前端开发国际性网站:第一次来给 V2EX 灌水,求支持~

  •  
  •   FuGardenia · 2015-10-10 14:51:47 +08:00 · 2986 次点击
    这是一个创建于 3337 天前的主题,其中的信息可能已经有所发展或是发生改变。

    dev-i18n-web

    Using swig to develop international website

    Multi-language translation

    DEMO

    Chinese 简体中文

    zh

    English English

    en

    Japanese 日本語

    ja

    Korean 한국어

    ko

    Add more languages, Such as zh-TW

    lib/html/**/*.tpl are for Large chunks of text.

    lib/json/*.json are for tinytext.

    • make JSON File
    mkdir lib/json/zh-tw.json
    
    • add "tw": "繁體中文" to langName and "tw": "../zh-t/index.html" to langUrl in each language JSON file
    "langName": {
        "en": "English",
        "zh": "简体中文",
        "jp": "日本語",
        "ko": "한국어",
        "tw": "繁體中文"
      },
      "langUrl": {
        "zh": "../zh-cn/index.html",
        "en": "../en-us/index.html",
        "jp": "../jp/index.html",
        "ko": "../korea/index.html",
        "tw": "../zh-tw/index.html"
      },
    
    • Translate JSON data into traditional Stadium Chinese(繁體中文)

    • Translate lib/html/**/*.tpl to lib/html/zh-t/*.tpl

    • gulpfile.js

    var output = {
      ...,
      tw: path.join(outputDir, 'zh-tw')
    }
    gulp.task('twTmp', function() {
      return gulp.src(source.htmlFileDir)
        .pipe(data(getJsonData('tw')))
        .pipe(swig())
        .pipe(gulp.dest(output.tw));
    });
    
    gulp.task('build', [
      ...,
      twTmp
    ]);
    
    • _header.tpl
    <span class="divider">|</span>
      <a class="lang-ko-a" href="{{langUrl.tw}}">{{langName.tw}}</a>
    
    • END (you can change for your website)
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3114 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 13:51 · PVG 21:51 · LAX 05:51 · JFK 08:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.