Commit 9f9b38f8 authored by JC Brand's avatar JC Brand

Some i18n fixes

The __ translate method should only be run *after* converse.js has been
initialized and we know what the actual desired language is

Also fix bug in src/locales.js where wrong langs were assigned to wrong keys.
parent c370b3e9
......@@ -312,6 +312,7 @@
// Translation machinery
// ---------------------
this.i18n = settings.i18n ? settings.i18n : locales.en;
var __ = utils.__.bind(this);
// Default configuration values
......
......@@ -29,7 +29,7 @@
// For translations
var __ = utils.__.bind(converse);
var ___ = utils.___;
// Add Strophe Namespaces
Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin");
Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner");
......
......@@ -21,6 +21,9 @@
var $ = converse_api.env.jQuery,
_ = converse_api.env._;
// For translations
var __ = utils.__.bind(converse);
var HAS_CSPRNG = ((typeof crypto !== 'undefined') &&
((typeof crypto.randomBytes === 'function') ||
(typeof crypto.getRandomValues === 'function')
......@@ -36,24 +39,13 @@
var VERIFIED= 2;
var FINISHED = 3;
var OTR_TRANSLATED_MAPPING = {}; // Populated in initialize
var OTR_CLASS_MAPPING = {};
OTR_CLASS_MAPPING[UNENCRYPTED] = 'unencrypted';
OTR_CLASS_MAPPING[UNVERIFIED] = 'unverified';
OTR_CLASS_MAPPING[VERIFIED] = 'verified';
OTR_CLASS_MAPPING[FINISHED] = 'finished';
// Translation aware constants
// ---------------------------
var __ = utils.__.bind(converse);
var OTR_TRANSLATED_MAPPING = {};
OTR_TRANSLATED_MAPPING[UNENCRYPTED] = __('unencrypted');
OTR_TRANSLATED_MAPPING[UNVERIFIED] = __('unverified');
OTR_TRANSLATED_MAPPING[VERIFIED] = __('verified');
OTR_TRANSLATED_MAPPING[FINISHED] = __('finished');
converse_api.plugins.add('otr', {
overrides: {
......@@ -477,6 +469,17 @@
* loaded by converse.js's plugin machinery.
*/
var converse = this.converse;
// Translation aware constants
// ---------------------------
// We can only call the __ translation method *after* converse.js
// has been initialized and with it the i18n machinery. That's why
// we do it here in the "initialize" method and not at the top of
// the module.
OTR_TRANSLATED_MAPPING[UNENCRYPTED] = __('unencrypted');
OTR_TRANSLATED_MAPPING[UNVERIFIED] = __('unverified');
OTR_TRANSLATED_MAPPING[VERIFIED] = __('verified');
OTR_TRANSLATED_MAPPING[FINISHED] = __('finished');
// For translations
__ = utils.__.bind(converse);
// Configuration values for this plugin
......
......@@ -77,7 +77,6 @@
*/
var converse = this.converse;
// For translations
__ = utils.__.bind(converse);
// Configuration values for this plugin
var settings = {
allow_registration: true,
......
......@@ -27,23 +27,23 @@
'text!zh'
], function ($, Jed) {
root.locales = {
'af': arguments[2],
'de': arguments[3],
'en': arguments[4],
'es': arguments[5],
'fr': arguments[6],
'he': arguments[7],
'hu': arguments[8],
'id': arguments[9],
'it': arguments[10],
'ja': arguments[11],
'nb': arguments[12],
'nl': arguments[13],
'pl': arguments[14],
'pt-br': arguments[15],
'ru': arguments[16],
'uk': arguments[17],
'zh': arguments[18]
'af': arguments[1],
'de': arguments[2],
'en': arguments[3],
'es': arguments[4],
'fr': arguments[5],
'he': arguments[6],
'hu': arguments[7],
'id': arguments[8],
'it': arguments[9],
'ja': arguments[10],
'nb': arguments[11],
'nl': arguments[12],
'pl': arguments[13],
'pt-br': arguments[14],
'ru': arguments[15],
'uk': arguments[16],
'zh': arguments[17]
};
return root.locales;
});
......
/*global escape locales */
/*global escape, locales, Jed */
(function (root, factory) {
define([
"jquery",
......
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