Makara - Dust.js 的国际化模块


Apache
跨平台
JavaScript

软件简介

Makara 是 Paypal 的开源项目,是 Dust.js
的国际化(i18n)模块,用于加载某个特定位置的内容。

示例

var i18n = require('makara');
var provider = i18n.create(config);
provider.getBundle('index', 'en_US', function (err, bundle) {
    var string = bundle.get('key');
});


var express = require('express'),
    i18n = require('makara'),
    dustjs = require('adaro');
var app = express();
app.engine('dust', dustjs.dust({ cache: false }));
app.engine('js', dustjs.js({ cache: false }));
app.set('views', 'path/to/templates');
app.set('view engine', 'dust');
app.set('view cache', false);
// Decorate express app with localized template rendering capabilities.
i18n.create(app, config);

Configuration

Required

  • contentPath (contentRoot) - (String)

  • fallback (fallbackLocale) - (String, Object)

  • templatePath (templateRoot) - (String)

Optional

  • enableMetadata (enableHtmlMetadata) - (boolean, default: false)

  • cache - (boolean, default: false)