On Github theosp / developing-tap-i18n-talk
<template name="x">
{{_ "click"}}
</template>
en.i18n.json {
"click": "Click Here"
}
Result Click Here
<template name="x">
{{_ "hello" "Daniel" "2014-05-22"}}
</template>
en.i18n.json {
"hello": "Hello %s, your last visit was on: %s"
}
Result Hello Daniel, your last visit was on: 2014-05-22
<template name="x">
{{_ "hello" "2014-05-22" user_name="Daniel"}}
</template>
en.i18n.json {
"hello": "Hello __user_name__, your last visit was on: %s"
}
Result Hello Daniel, your last visit was on: 2014-05-22
<template name="x">
{{_ "inbox_status" "2014-05-22" username="Daniel" count=1}}
{{_ "inbox_status" "2014-05-22" username="Chris" count=4}}
</template>
en.i18n.json {
"inbox_status": "__username__, You have a new message (inbox last checked %s)",
"inbox_status_plural": "__username__, You have __count__ new messages (last checked %s)"
}
Result Daniel, You have a new message (inbox last checked 2014-05-22) Chris, You have 4 new messages (last checked 2014-05-22)
<template name="x">
{{_ "actors_count" count=1 context="male" }}
{{_ "actors_count" count=2 context="female" }}
</template>
en.i18n.json {
"actors_count": "There is one actor in the movie",
"actors_count_male": "There is one actor in the movie",
"actors_count_female": "There is one actress in the movie",
"actors_count_plural": "There are __count__ actors in the movie",
"actors_count_male_plural": "There are __count__ actors in the movie",
"actors_count_female_plural": "There are __count__ actresses in the movie",
}
Result There is one actor in the movie There are 2 actresses in the movie
Package.on_use(function (api) {
api.export('Deps');
api.add_files('deps.js');
api.add_files('deprecated.js');
});
Package.on_use(function (api) {
api.use(["coffeescript", "underscore", "meteor"], ['server', 'client']);
api.use(["http-methods"], 'server');
api.use(["deps", "session", "jquery", "templating"], 'client');
// load and init TAPi18next
api.add_files('lib/tap_i18next/tap_i18next-1.7.3.js', 'client');
api.export("TAPi18next");
api.add_files('lib/tap_i18next/tap_i18next_init.js', 'client');
// load TAPi18n
api.add_files('lib/globals.js', ['client', 'server']);
api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'server');
// We use the bare option since we need TAPi18n in the package level
// and coffee adds vars to all (so without bare all vars are in the
// file level)
api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'client',
{bare: true});
api.add_files('lib/tap_i18n/tap_i18n-server.coffee', 'server');
api.add_files('lib/tap_i18n/tap_i18n-client.coffee', 'client',
{bare: true});
api.export("TAPi18n");
});
Package._transitional_registerBuildPlugin({
name: "compileLess",
use: [],
sources: [
'plugin/compile-less.js'
],
npmDependencies: {"less": "1.6.1"}
});
Plugin.registerSourceHandler("less", function (compileStep) {
//
// compilation code
//
compileStep.addStylesheet({
path: compileStep.inputPath + ".css",
data: css,
sourceMap: sourceMap
});
});;
// Register import.less files with the dependency watcher, without actually
// processing them. There is a similar rule in the stylus package.
Plugin.registerSourceHandler("import.less", function () {
// Do nothing
});
// Backward compatibility with Meteor 0.7
Plugin.registerSourceHandler("lessimport", function () {});
// Register our build plugin
Package._transitional_registerBuildPlugin({
name: "compileI18n",
use: ["coffeescript", "meteor", "simple-schema", "check", "templating"],
sources: [
'lib/globals.js',
'lib/plugin/wrench.js',
'lib/plugin/language_names.js',
'lib/plugin/compile-i18n.coffee'
]
});
Plugin.registerSourceHandler "i18n", (compileStep) -> ... Plugin.registerSourceHandler "package-tap.i18n", (compileStep) -> ... Plugin.registerSourceHandler "project-tap.i18n", (compileStep) -> ... Plugin.registerSourceHandler "i18n.json", (compileStep) -> ...
Package.on_use(function (api) {
api.use(["tap-i18n"], ["client", "server"]);
// You must load your package's package-tap.i18n before you load any
// template
api.add_files("package-tap.i18n", ["client", "server"]);
// Templates loads (if any)
// You must load the languages files after you load your templates -
// otherwise the templates won't have the i18n capabilities (unless
// you'll register them with tap-i18n yourself, see below).
api.add_files([
"i18n/en.i18n.json",
"i18n/fr.i18n.json",
"i18n/pt.i18n.json",
"i18n/pt-br.i18n.json"
], ["client"]);
});