Commit 31cb3d4b authored by JC Brand's avatar JC Brand

Fix the non-AMD case.

parent 0a1a98d2
...@@ -4,6 +4,7 @@ module.exports = function(grunt) { ...@@ -4,6 +4,7 @@ module.exports = function(grunt) {
jst: { jst: {
compile: { compile: {
options: { options: {
namespace: 'templates',
templateSettings: { templateSettings: {
evaluate : /\{\[([\s\S]+?)\]\}/g, evaluate : /\{\[([\s\S]+?)\]\}/g,
interpolate : /\{\{([\s\S]+?)\}\}/g interpolate : /\{\{([\s\S]+?)\}\}/g
...@@ -20,6 +21,20 @@ module.exports = function(grunt) { ...@@ -20,6 +21,20 @@ module.exports = function(grunt) {
} }
}, },
json: {
main: {
options: {
namespace: 'locales',
includePath: true,
processName: function(filename) {
return filename.toLowerCase().match(/^locale\/(.*)\/lc_messages/)[1];
}
},
src: ['locale/**/LC_MESSAGES/*.json'],
dest: 'builds/locales.js'
}
},
jshint: { jshint: {
options: { options: {
trailing: true trailing: true
...@@ -52,6 +67,7 @@ module.exports = function(grunt) { ...@@ -52,6 +67,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jst'); grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-json');
grunt.loadNpmTasks('grunt-contrib-requirejs'); grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('test', 'Run Tests', function () { grunt.registerTask('test', 'Run Tests', function () {
......
This diff is collapsed.
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
} }
); );
} else { } else {
root.converse = factory(jQuery, _, OTR, DSA, JST, moment, utils); root.converse = factory(jQuery, _, OTR, DSA, templates, moment, utils);
} }
}(this, function ($, _, OTR, DSA, templates, moment, utils) { }(this, function ($, _, OTR, DSA, templates, moment, utils) {
// "use strict"; // "use strict";
...@@ -282,6 +282,8 @@ ...@@ -282,6 +282,8 @@
// Allow only whitelisted configuration attributes to be overwritten // Allow only whitelisted configuration attributes to be overwritten
_.extend(this, _.pick(settings, Object.keys(default_settings))); _.extend(this, _.pick(settings, Object.keys(default_settings)));
this.jed = new Jed(this.i18n);
if (settings.visible_toolbar_buttons) { if (settings.visible_toolbar_buttons) {
_.extend( _.extend(
this.visible_toolbar_buttons, this.visible_toolbar_buttons,
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<link type="text/css" rel="stylesheet" media="screen" href="components/fontawesome/css/font-awesome.min.css" /> <link type="text/css" rel="stylesheet" media="screen" href="components/fontawesome/css/font-awesome.min.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script type="text/javascript" src="analytics.js"></script>
<script data-main="main" src="components/requirejs/require.js"></script> <script data-main="main" src="components/requirejs/require.js"></script>
</head> </head>
......
...@@ -7,40 +7,6 @@ ...@@ -7,40 +7,6 @@
(function (root, factory) { (function (root, factory) {
define("locales", ['jquery', 'jed', define("locales", ['jquery', 'jed',
'text!af',
'text!de',
'text!en',
'text!es',
'text!fr',
'text!he',
'text!hu',
'text!id',
'text!it',
'text!ja',
'text!nb',
'text!nl',
'text!pl',
'text!pt_BR',
'text!ru',
'text!zh'
], function ($, Jed, af, de, en, es, fr, he, hu, id, it, ja, nb, nl, pl, pt_BR, ru, zh) { ], function ($, Jed, af, de, en, es, fr, he, hu, id, it, ja, nb, nl, pl, pt_BR, ru, zh) {
root.locales = {
'af': new Jed($.parseJSON(af)),
'de': new Jed($.parseJSON(de)),
'en': new Jed($.parseJSON(en)),
'es': new Jed($.parseJSON(es)),
'fr': new Jed($.parseJSON(fr)),
'he': new Jed($.parseJSON(he)),
'hu': new Jed($.parseJSON(hu)),
'id': new Jed($.parseJSON(id)),
'it': new Jed($.parseJSON(it)),
'ja': new Jed($.parseJSON(ja)),
'nb': new Jed($.parseJSON(nb)),
'nl': new Jed($.parseJSON(nl)),
'pl': new Jed($.parseJSON(pl)),
'pt-br': new Jed($.parseJSON(pt_BR)),
'ru': new Jed($.parseJSON(ru)),
'zh': new Jed($.parseJSON(zh))
};
}); });
})(this); })(this);
This diff is collapsed.
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
"po2json": "^0.3.0" "po2json": "^0.3.0"
}, },
"dependencies": { "dependencies": {
"grunt-json": "^0.1.3",
"requirejs": "~2.1.11" "requirejs": "~2.1.11"
} }
} }
define(["jquery", "converse-templates"], function ($, templates) { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(["jquery", "converse-templates", "locales"], factory);
} else {
root.utils = factory(jQuery, templates);
}
}(this, function ($, templates) {
"use strict"; "use strict";
var XFORM_TYPE_MAP = { var XFORM_TYPE_MAP = {
...@@ -49,10 +55,13 @@ define(["jquery", "converse-templates"], function ($, templates) { ...@@ -49,10 +55,13 @@ define(["jquery", "converse-templates"], function ($, templates) {
// --------------------- // ---------------------
__: function (str) { __: function (str) {
// Translation factory // Translation factory
if (this.i18n === undefined) { if (typeof this.i18n === "undefined") {
this.i18n = locales.en; this.i18n = locales.en;
} }
var t = this.i18n.translate(str); if (typeof this.jed === "undefined") {
this.jed = new Jed(this.i18n);
}
var t = this.jed.translate(str);
if (arguments.length>1) { if (arguments.length>1) {
return t.fetch.apply(t, [].slice.call(arguments,1)); return t.fetch.apply(t, [].slice.call(arguments,1));
} else { } else {
...@@ -186,4 +195,4 @@ define(["jquery", "converse-templates"], function ($, templates) { ...@@ -186,4 +195,4 @@ define(["jquery", "converse-templates"], function ($, templates) {
} }
}; };
return utils; return utils;
}); }));
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