Commit 96281893 authored by JC Brand's avatar JC Brand

Can't call i18n.translate directly if we bundle without i18n support

parent 1d6f2dbe
......@@ -35,7 +35,7 @@ help:
@echo " text to make text files"
pot:
xgettext --keyword=__ --keyword=translate --from-code=UTF-8 --output=locale/converse.pot converse.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=0.4 -c --language="python";
xgettext --keyword=__ --keyword=___ --from-code=UTF-8 --output=locale/converse.pot converse.js --package-name=Converse.js --copyright-holder="Jan-Carel Brand" --package-version=0.4 -c --language="python";
release:
r.js -o build.js
......
......@@ -76,6 +76,8 @@
_.extend(this, _.pick(settings, whitelist));
var __ = $.proxy(function (str) {
/* Translation factory
*/
if (this.i18n === undefined) {
return str;
}
......@@ -86,6 +88,18 @@
return t.fetch();
}
}, this);
var ___ = function (str) {
/* XXX: This is part of a hack to get gettext to scan strings to be
* translated. Strings we cannot send to the function above because
* they require variable interpolation and we don't yet have the
* variables at scan time.
*
* See actionInfoMessages
*/
return str;
};
this.msg_counter = 0;
this.autoLink = function (text) {
// Convert URLs into hyperlinks
......@@ -1427,22 +1441,20 @@
},
actionInfoMessages: {
// # For translations: %1$s will be replaced with the user's nickname
// # Don't translate "strong"
// # Example: <strong>jcbrand</strong> has been banned
301: converse.i18n.translate('<strong>%1$s</strong> has been banned'),
// # For translations: %1$s will be replaced with the user's nickname
// # Don't translate "strong"
// # Example: <strong>jcbrand</strong> has been kicked out
307: converse.i18n.translate('<strong>%1$s</strong> has been kicked out'),
// # For translations: %1$s will be replaced with the user's nickname
// # Don't translate "strong"
// # Example: <strong>jcbrand</strong> has been removed because of an affiliasion change
321: converse.i18n.translate("<strong>%1$s</strong> has been removed because of an affiliation change"),
// # For translations: %1$s will be replaced with the user's nickname
// # Don't translate "strong"
// # Example: <strong>jcbrand</strong> has been removed for not being a member
322: converse.i18n.translate("<strong>%1$s</strong> has been removed for not being a member")
/* XXX: Note the triple underscore function and not double
* underscore.
*
* This is a hack. We can't pass the strings to __ because we
* don't yet know what the variable to interpolate is.
*
* Triple underscore will just return the string again, but we
* can then at least tell gettext to scan for it so that these
* strings are picked up by the translation machinery.
*/
301: ___("<strong>%1$s</strong> has been banned"),
307: ___("<strong>%1$s</strong> has been kicked out"),
321: ___("<strong>%1$s</strong> has been removed because of an affiliation change"),
322: ___("<strong>%1$s</strong> has been removed for not being a member")
},
disconnectMessages: {
......@@ -1474,9 +1486,8 @@
info_msgs.push(this.infoMessages[stat]);
} else if (_.contains(_.keys(this.actionInfoMessages), stat)) {
action_msgs.push(
this.actionInfoMessages[stat].fetch(
Strophe.unescapeNode(Strophe.getResourceFromJid($el.attr('from')))
));
__(this.actionInfoMessages[stat], Strophe.unescapeNode(Strophe.getResourceFromJid($el.attr('from'))))
);
}
}
}
......
......@@ -168,7 +168,7 @@
prebind: false,
show_controlbox_by_default: true,
xhr_user_search: false,
debug: false
debug: true
});
});
</script>
......
......@@ -3,10 +3,10 @@ require.config({
paths: {
"jquery": "components/jquery/jquery",
"locales": "locale/locales",
"tinysort": "components/tinysort/src/jquery.tinysort",
"jquery.tinysort": "components/tinysort/src/jquery.tinysort",
"underscore": "components/underscore/underscore",
"backbone": "components/backbone/backbone",
"localstorage": "components/backbone.localStorage/backbone.localStorage",
"backbone.localStorage": "components/backbone.localStorage/backbone.localStorage",
"strophe": "components/strophe/strophe",
"strophe.muc": "components/strophe.muc/index",
"strophe.roster": "components/strophe.roster/index",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment