mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
comments: Update comment for zjsunit/i18n.js.
This commit is contained in:
@@ -1,10 +1,20 @@
|
|||||||
exports.t = function (str, context) {
|
exports.t = function (str, context) {
|
||||||
// We are currently assuming that we will receive context in form of a Dict
|
// HAPPY PATH: most translations are a simple string:
|
||||||
// of key value pairs and string will be having substitution for keywords
|
|
||||||
// like these "__keyword__".
|
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
return 'translated: ' + str;
|
return 'translated: ' + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
context will be an ordinary JS object like this:
|
||||||
|
|
||||||
|
{minutes: minutes.toString()}
|
||||||
|
|
||||||
|
This supports use cases like the following:
|
||||||
|
|
||||||
|
i18n.t("__minutes__ min to edit", {minutes: minutes.toString()})
|
||||||
|
|
||||||
|
We have to munge in the context here.
|
||||||
|
*/
|
||||||
const keyword_regex = /__(- )?(\w)+__/g;
|
const keyword_regex = /__(- )?(\w)+__/g;
|
||||||
const keys_in_str = str.match(keyword_regex);
|
const keys_in_str = str.match(keyword_regex);
|
||||||
const substitutions = _.map(keys_in_str, function (key) {
|
const substitutions = _.map(keys_in_str, function (key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user