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: ...@@ -35,7 +35,7 @@ help:
@echo " text to make text files" @echo " text to make text files"
pot: 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: release:
r.js -o build.js r.js -o build.js
......
...@@ -76,6 +76,8 @@ ...@@ -76,6 +76,8 @@
_.extend(this, _.pick(settings, whitelist)); _.extend(this, _.pick(settings, whitelist));
var __ = $.proxy(function (str) { var __ = $.proxy(function (str) {
/* Translation factory
*/
if (this.i18n === undefined) { if (this.i18n === undefined) {
return str; return str;
} }
...@@ -86,6 +88,18 @@ ...@@ -86,6 +88,18 @@
return t.fetch(); return t.fetch();
} }
}, this); }, 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.msg_counter = 0;
this.autoLink = function (text) { this.autoLink = function (text) {
// Convert URLs into hyperlinks // Convert URLs into hyperlinks
...@@ -1427,22 +1441,20 @@ ...@@ -1427,22 +1441,20 @@
}, },
actionInfoMessages: { actionInfoMessages: {
// # For translations: %1$s will be replaced with the user's nickname /* XXX: Note the triple underscore function and not double
// # Don't translate "strong" * underscore.
// # Example: <strong>jcbrand</strong> has been banned *
301: converse.i18n.translate('<strong>%1$s</strong> has been banned'), * This is a hack. We can't pass the strings to __ because we
// # For translations: %1$s will be replaced with the user's nickname * don't yet know what the variable to interpolate is.
// # Don't translate "strong" *
// # Example: <strong>jcbrand</strong> has been kicked out * Triple underscore will just return the string again, but we
307: converse.i18n.translate('<strong>%1$s</strong> has been kicked out'), * can then at least tell gettext to scan for it so that these
// # For translations: %1$s will be replaced with the user's nickname * strings are picked up by the translation machinery.
// # Don't translate "strong" */
// # Example: <strong>jcbrand</strong> has been removed because of an affiliasion change 301: ___("<strong>%1$s</strong> has been banned"),
321: converse.i18n.translate("<strong>%1$s</strong> has been removed because of an affiliation change"), 307: ___("<strong>%1$s</strong> has been kicked out"),
// # For translations: %1$s will be replaced with the user's nickname 321: ___("<strong>%1$s</strong> has been removed because of an affiliation change"),
// # Don't translate "strong" 322: ___("<strong>%1$s</strong> has been removed for not being a member")
// # 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")
}, },
disconnectMessages: { disconnectMessages: {
...@@ -1474,9 +1486,8 @@ ...@@ -1474,9 +1486,8 @@
info_msgs.push(this.infoMessages[stat]); info_msgs.push(this.infoMessages[stat]);
} else if (_.contains(_.keys(this.actionInfoMessages), stat)) { } else if (_.contains(_.keys(this.actionInfoMessages), stat)) {
action_msgs.push( action_msgs.push(
this.actionInfoMessages[stat].fetch( __(this.actionInfoMessages[stat], Strophe.unescapeNode(Strophe.getResourceFromJid($el.attr('from'))))
Strophe.unescapeNode(Strophe.getResourceFromJid($el.attr('from'))) );
));
} }
} }
} }
......
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
prebind: false, prebind: false,
show_controlbox_by_default: true, show_controlbox_by_default: true,
xhr_user_search: false, xhr_user_search: false,
debug: false debug: true
}); });
}); });
</script> </script>
......
...@@ -3,10 +3,10 @@ require.config({ ...@@ -3,10 +3,10 @@ require.config({
paths: { paths: {
"jquery": "components/jquery/jquery", "jquery": "components/jquery/jquery",
"locales": "locale/locales", "locales": "locale/locales",
"tinysort": "components/tinysort/src/jquery.tinysort", "jquery.tinysort": "components/tinysort/src/jquery.tinysort",
"underscore": "components/underscore/underscore", "underscore": "components/underscore/underscore",
"backbone": "components/backbone/backbone", "backbone": "components/backbone/backbone",
"localstorage": "components/backbone.localStorage/backbone.localStorage", "backbone.localStorage": "components/backbone.localStorage/backbone.localStorage",
"strophe": "components/strophe/strophe", "strophe": "components/strophe/strophe",
"strophe.muc": "components/strophe.muc/index", "strophe.muc": "components/strophe.muc/index",
"strophe.roster": "components/strophe.roster/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