Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
24e4dac2b8
28
Makefile
28
Makefile
@ -172,33 +172,33 @@ BUILDS = dist/converse.js \
|
|||||||
dist/converse-no-dependencies.min.js \
|
dist/converse-no-dependencies.min.js \
|
||||||
dist/converse-no-dependencies.js
|
dist/converse-no-dependencies.js
|
||||||
|
|
||||||
dist/converse.js: transpile src locale node_modules *.js
|
dist/converse.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build.js include=converse out=dist/converse.js optimize=none
|
$(RJS) -o src/build.js include=converse out=dist/converse.js optimize=none
|
||||||
dist/converse.min.js: src locale node_modules *.js
|
dist/converse.min.js: src node_modules *.js
|
||||||
$(RJS) -o src/build.js include=converse out=dist/converse.min.js
|
$(RJS) -o src/build.js include=converse out=dist/converse.min.js
|
||||||
dist/converse-esnext.js: src locale node_modules *.js transpile
|
dist/converse-esnext.js: src node_modules *.js transpile
|
||||||
$(RJS) -o src/build-esnext.js include=converse out=dist/converse-esnext.js optimize=none
|
$(RJS) -o src/build-esnext.js include=converse out=dist/converse-esnext.js optimize=none
|
||||||
dist/converse-esnext.min.js: src locale node_modules *.js transpile
|
dist/converse-esnext.min.js: src node_modules *.js transpile
|
||||||
$(RJS) -o src/build-esnext.js include=converse out=dist/converse-esnext.min.js
|
$(RJS) -o src/build-esnext.js include=converse out=dist/converse-esnext.min.js
|
||||||
dist/inverse.js: transpile src locale node_modules *.js
|
dist/inverse.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build-inverse.js include=inverse out=dist/inverse.js optimize=none
|
$(RJS) -o src/build-inverse.js include=inverse out=dist/inverse.js optimize=none
|
||||||
dist/inverse.min.js: src locale node_modules *.js
|
dist/inverse.min.js: src node_modules *.js
|
||||||
$(RJS) -o src/build-inverse.js include=inverse out=dist/inverse.min.js
|
$(RJS) -o src/build-inverse.js include=inverse out=dist/inverse.min.js
|
||||||
dist/converse-no-jquery.js: transpile src locale node_modules *.js
|
dist/converse-no-jquery.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery.noconflict out=dist/converse-no-jquery.js optimize=none
|
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery.noconflict out=dist/converse-no-jquery.js optimize=none
|
||||||
dist/converse-no-jquery.min.js: src locale node_modules *.js transpile
|
dist/converse-no-jquery.min.js: src node_modules *.js transpile
|
||||||
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery.noconflict out=dist/converse-no-jquery.min.js
|
$(RJS) -o src/build.js include=converse wrap.endFile=end-no-jquery.frag exclude=jquery exclude=jquery.noconflict out=dist/converse-no-jquery.min.js
|
||||||
dist/converse-no-dependencies.js: transpile src locale node_modules *.js
|
dist/converse-no-dependencies.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build-no-dependencies.js optimize=none out=dist/converse-no-dependencies.js
|
$(RJS) -o src/build-no-dependencies.js optimize=none out=dist/converse-no-dependencies.js
|
||||||
dist/converse-no-dependencies.min.js: src locale node_modules *.js
|
dist/converse-no-dependencies.min.js: src node_modules *.js
|
||||||
$(RJS) -o src/build-no-dependencies.js out=dist/converse-no-dependencies.min.js
|
$(RJS) -o src/build-no-dependencies.js out=dist/converse-no-dependencies.min.js
|
||||||
dist/converse-mobile.js: transpile src locale node_modules *.js
|
dist/converse-mobile.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build.js paths.converse=src/converse-mobile include=converse out=dist/converse-mobile.js optimize=none
|
$(RJS) -o src/build.js paths.converse=src/converse-mobile include=converse out=dist/converse-mobile.js optimize=none
|
||||||
dist/converse-mobile.min.js: src locale node_modules *.js
|
dist/converse-mobile.min.js: src node_modules *.js
|
||||||
$(RJS) -o src/build.js paths.converse=src/converse-mobile include=converse out=dist/converse-mobile.min.js
|
$(RJS) -o src/build.js paths.converse=src/converse-mobile include=converse out=dist/converse-mobile.min.js
|
||||||
dist/converse-muc-embedded.js: transpile src locale node_modules *.js
|
dist/converse-muc-embedded.js: transpile src node_modules *.js
|
||||||
$(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.js optimize=none
|
$(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.js optimize=none
|
||||||
dist/converse-muc-embedded.min.js: src locale node_modules *.js
|
dist/converse-muc-embedded.min.js: src node_modules *.js
|
||||||
$(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.min.js
|
$(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.min.js
|
||||||
|
|
||||||
.PHONY: jsmin
|
.PHONY: jsmin
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file can be used if no locale support is required.
|
|
||||||
*/
|
|
||||||
(function (root, factory) {
|
|
||||||
define("locales", ['jed'], function (Jed) {
|
|
||||||
var translations = {
|
|
||||||
"domain": "converse",
|
|
||||||
"locale_data": {
|
|
||||||
"converse": {
|
|
||||||
"": {
|
|
||||||
"domain": "converse",
|
|
||||||
"lang": "en",
|
|
||||||
"plural_forms": "nplurals=2; plural=(n != 1);"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
root.locales = { 'en': new Jed(translations) };
|
|
||||||
});
|
|
||||||
})(this);
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file specifies a single language dependency (for English).
|
|
||||||
*
|
|
||||||
* Translations take up a lot of space and you are therefore advised to remove
|
|
||||||
* from here any languages that you don't need.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function (root, factory) {
|
|
||||||
require.config({
|
|
||||||
paths: {
|
|
||||||
"jed": "Libraries/jed",
|
|
||||||
"en": "locale/en/LC_MESSAGES/en"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
define("locales", [
|
|
||||||
'jed',
|
|
||||||
'en'
|
|
||||||
], function (jed, en) {
|
|
||||||
root.locales = {};
|
|
||||||
root.locales.en = en;
|
|
||||||
});
|
|
||||||
})(this);
|
|
@ -26,6 +26,7 @@ require.config({
|
|||||||
"es6-promise": "node_modules/es6-promise/dist/es6-promise.auto",
|
"es6-promise": "node_modules/es6-promise/dist/es6-promise.auto",
|
||||||
"eventemitter": "node_modules/otr/build/dep/eventemitter",
|
"eventemitter": "node_modules/otr/build/dep/eventemitter",
|
||||||
"form-utils": "src/form-utils",
|
"form-utils": "src/form-utils",
|
||||||
|
"jed": "node_modules/jed/jed",
|
||||||
"jquery": "node_modules/jquery/dist/jquery",
|
"jquery": "node_modules/jquery/dist/jquery",
|
||||||
"jquery.browser": "node_modules/jquery.browser/dist/jquery.browser",
|
"jquery.browser": "node_modules/jquery.browser/dist/jquery.browser",
|
||||||
"jquery.noconflict": "src/jquery.noconflict",
|
"jquery.noconflict": "src/jquery.noconflict",
|
||||||
@ -33,10 +34,9 @@ require.config({
|
|||||||
"lodash.converter": "3rdparty/lodash.fp",
|
"lodash.converter": "3rdparty/lodash.fp",
|
||||||
"lodash.fp": "src/lodash.fp",
|
"lodash.fp": "src/lodash.fp",
|
||||||
"lodash.noconflict": "src/lodash.noconflict",
|
"lodash.noconflict": "src/lodash.noconflict",
|
||||||
|
"moment_with_locales": "3rdparty/moment_locales",
|
||||||
"pluggable": "node_modules/pluggable.js/dist/pluggable",
|
"pluggable": "node_modules/pluggable.js/dist/pluggable",
|
||||||
"polyfill": "src/polyfill",
|
"polyfill": "src/polyfill",
|
||||||
"virtual-dom": "node_modules/virtual-dom/dist/virtual-dom",
|
|
||||||
"vdom-parser": "node_modules/vdom-parser/dist",
|
|
||||||
"sizzle": "node_modules/jquery/sizzle/dist/sizzle",
|
"sizzle": "node_modules/jquery/sizzle/dist/sizzle",
|
||||||
"strophe": "node_modules/strophe.js/strophe",
|
"strophe": "node_modules/strophe.js/strophe",
|
||||||
"strophe.disco": "node_modules/strophejs-plugin-disco/strophe.disco",
|
"strophe.disco": "node_modules/strophejs-plugin-disco/strophe.disco",
|
||||||
@ -47,6 +47,8 @@ require.config({
|
|||||||
"tpl": "node_modules/lodash-template-loader/loader",
|
"tpl": "node_modules/lodash-template-loader/loader",
|
||||||
"underscore": "src/underscore-shim",
|
"underscore": "src/underscore-shim",
|
||||||
"utils": "src/utils",
|
"utils": "src/utils",
|
||||||
|
"vdom-parser": "node_modules/vdom-parser/dist",
|
||||||
|
"virtual-dom": "node_modules/virtual-dom/dist/virtual-dom",
|
||||||
"xss": "node_modules/xss/dist/xss",
|
"xss": "node_modules/xss/dist/xss",
|
||||||
"xss.noconflict": "src/xss.noconflict",
|
"xss.noconflict": "src/xss.noconflict",
|
||||||
|
|
||||||
@ -82,29 +84,6 @@ require.config({
|
|||||||
"crypto": "node_modules/otr/build/dep/crypto",
|
"crypto": "node_modules/otr/build/dep/crypto",
|
||||||
"salsa20": "node_modules/otr/build/dep/salsa20",
|
"salsa20": "node_modules/otr/build/dep/salsa20",
|
||||||
"otr": "node_modules/otr/build/otr",
|
"otr": "node_modules/otr/build/otr",
|
||||||
|
|
||||||
// Locales paths
|
|
||||||
"locales": "src/locales",
|
|
||||||
"jed": "node_modules/jed/jed",
|
|
||||||
"af": "locale/af/LC_MESSAGES/converse.json",
|
|
||||||
"ca": "locale/ca/LC_MESSAGES/converse.json",
|
|
||||||
"de": "locale/de/LC_MESSAGES/converse.json",
|
|
||||||
"es": "locale/es/LC_MESSAGES/converse.json",
|
|
||||||
"fr": "locale/fr/LC_MESSAGES/converse.json",
|
|
||||||
"he": "locale/he/LC_MESSAGES/converse.json",
|
|
||||||
"hu": "locale/hu/LC_MESSAGES/converse.json",
|
|
||||||
"id": "locale/id/LC_MESSAGES/converse.json",
|
|
||||||
"it": "locale/it/LC_MESSAGES/converse.json",
|
|
||||||
"ja": "locale/ja/LC_MESSAGES/converse.json",
|
|
||||||
"nb": "locale/nb/LC_MESSAGES/converse.json",
|
|
||||||
"nl": "locale/nl/LC_MESSAGES/converse.json",
|
|
||||||
"pl": "locale/pl/LC_MESSAGES/converse.json",
|
|
||||||
"pt_BR": "locale/pt_BR/LC_MESSAGES/converse.json",
|
|
||||||
"ru": "locale/ru/LC_MESSAGES/converse.json",
|
|
||||||
"uk": "locale/uk/LC_MESSAGES/converse.json",
|
|
||||||
"zh": "locale/zh/LC_MESSAGES/converse.json",
|
|
||||||
|
|
||||||
"moment_with_locales": "3rdparty/moment_locales",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
packages: [{
|
packages: [{
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"es6-promise",
|
"es6-promise",
|
||||||
"lodash.noconflict",
|
"lodash.noconflict",
|
||||||
"polyfill",
|
"polyfill",
|
||||||
|
"jed",
|
||||||
"utils",
|
"utils",
|
||||||
"moment_with_locales",
|
"moment_with_locales",
|
||||||
"strophe",
|
"strophe",
|
||||||
@ -18,9 +19,7 @@
|
|||||||
"backbone.browserStorage",
|
"backbone.browserStorage",
|
||||||
"backbone.overview",
|
"backbone.overview",
|
||||||
], factory);
|
], factory);
|
||||||
}(this, function (
|
}(this, function (sizzle, Promise, _, polyfill, Jed, utils, moment, Strophe, pluggable, Backbone) {
|
||||||
sizzle, Promise, _, polyfill,
|
|
||||||
utils, moment, Strophe, pluggable, Backbone) {
|
|
||||||
|
|
||||||
/* Cannot use this due to Safari bug.
|
/* Cannot use this due to Safari bug.
|
||||||
* See https://github.com/jcbrand/converse.js/issues/196
|
* See https://github.com/jcbrand/converse.js/issues/196
|
||||||
@ -52,7 +51,8 @@
|
|||||||
_.templateSettings = {
|
_.templateSettings = {
|
||||||
'escape': /\{\{\{([\s\S]+?)\}\}\}/g,
|
'escape': /\{\{\{([\s\S]+?)\}\}\}/g,
|
||||||
'evaluate': /\{\[([\s\S]+?)\]\}/g,
|
'evaluate': /\{\[([\s\S]+?)\]\}/g,
|
||||||
'interpolate': /\{\{([\s\S]+?)\}\}/g
|
'interpolate': /\{\{([\s\S]+?)\}\}/g,
|
||||||
|
'imports': { '_': _ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const _converse = {
|
const _converse = {
|
||||||
@ -131,6 +131,19 @@
|
|||||||
_converse.DEFAULT_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gwHCy455JBsggAABkJJREFUeNrtnM1PE1sUwHvvTD8otWLHST/Gimi1CEgr6M6FEWuIBo2pujDVsNDEP8GN/4MbN7oxrlipG2OCgZgYlxAbkRYw1KqkIDRCSkM7nXvvW8x7vjyNeQ9m7p1p3z1LQk/v/Dhz7vkEXL161cHl9wI5Ag6IA+KAOCAOiAPigDggLhwQB2S+iNZ+PcYY/SWEEP2HAAAIoSAIoihCCP+ngDDGtVotGAz29/cfOXJEUZSOjg6n06lp2sbGRqlUWlhYyGazS0tLbrdbEASrzgksyeYJId3d3el0uqenRxRFAAAA4KdfIIRgjD9+/Pj8+fOpqSndslofEIQwHA6Pjo4mEon//qmFhYXHjx8vLi4ihBgDEnp7e9l8E0Jo165dQ0NDd+/eDYVC2/qsJElDQ0OEkKWlpa2tLZamxAhQo9EIBoOjo6MXL17csZLe3l5FUT59+lQul5l5JRaAVFWNRqN37tw5ceKEQVWRSOTw4cOFQuHbt2+iKLYCIISQLMu3b99OJpOmKAwEAgcPHszn8+vr6wzsiG6UQQhxuVyXLl0aGBgwUW0sFstkMl6v90fo1KyAMMYDAwPnzp0zXfPg4GAqlWo0Gk0MiBAiy/L58+edTqf5Aa4onj59OhaLYYybFRCEMBaL0fNxBw4cSCQStN0QRUBut3t4eJjq6U+dOiVJElVPRBFQIBDo6+ujCqirqyscDlONGykC2lYyYSR6pBoQQapHZwAoHo/TuARYAOrs7GQASFEUqn6aIiBJkhgA6ujooFpUo6iaTa7koFwnaoWadLNe81tbWwzoaJrWrICWl5cZAFpbW6OabVAEtLi4yABQsVjUNK0pAWWzWQaAcrlcswKanZ1VVZUqHYRQEwOq1Wpv3ryhCmh6erpcLjd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okC1eMU3T0um0DZPMkZER6wERQnw+n/FFSxpy7Nix3bt3WwwIIcRgIWnHkkwmjecfRgGx7DtuV/r6+iwGhDHev3+/bQF1dnYaH6E2CkiWZdsC2rt3r8WAHA5HW1ubbQGZcjajgOwTH/4qNko1Wlg4IA6IA+KAOKBWBUQIsfNojyliKIoRRfH9+/dut9umf3wzpoUNNQ4BAJubmwz+ic+OxefzWWlBhJD29nbug7iT5sIBcUAcEAfEAXFAHBAHxOVn+QMrmWpuPZx12gAAAABJRU5ErkJggg==";
|
||||||
|
|
||||||
_converse.log = function (message, level) {
|
_converse.log = function (message, level) {
|
||||||
|
/* Logs messages to the browser's developer console.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (String) message - The message to be logged.
|
||||||
|
* (Integer) level - The loglevel which allows for filtering of log
|
||||||
|
* messages.
|
||||||
|
*
|
||||||
|
* Available loglevels are 0 for 'debug', 1 for 'info', 2 for 'warn',
|
||||||
|
* 3 for 'error' and 4 for 'fatal'.
|
||||||
|
*
|
||||||
|
* When using the 'error' or 'warn' loglevels, a full stacktrace will be
|
||||||
|
* logged as well.
|
||||||
|
*/
|
||||||
if (message instanceof Error) {
|
if (message instanceof Error) {
|
||||||
message = message.stack;
|
message = message.stack;
|
||||||
}
|
}
|
||||||
@ -163,6 +176,137 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ---------------------
|
||||||
|
// Translation machinery
|
||||||
|
// ---------------------
|
||||||
|
_converse.__ = function (str) {
|
||||||
|
/* Translate the given string based on the current locale.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (String) str - The string to translate.
|
||||||
|
*/
|
||||||
|
if (_.isUndefined(Jed)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
if (_.isUndefined(_converse.jed)) {
|
||||||
|
return Jed.sprintf.apply(Jed, arguments);
|
||||||
|
}
|
||||||
|
var t = _converse.jed.translate(str);
|
||||||
|
if (arguments.length>1) {
|
||||||
|
return t.fetch.apply(t, [].slice.call(arguments, 1));
|
||||||
|
} else {
|
||||||
|
return t.fetch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const detectLocale = function (library_check) {
|
||||||
|
/* Determine which locale is supported by the user's system as well
|
||||||
|
* as by the relevant library (e.g. converse.js or moment.js).
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (Function) library_check - Returns a boolean indicating whether
|
||||||
|
* the locale is supported.
|
||||||
|
*/
|
||||||
|
var locale, i;
|
||||||
|
if (window.navigator.userLanguage) {
|
||||||
|
locale = isLocaleAvailable(window.navigator.userLanguage, library_check);
|
||||||
|
}
|
||||||
|
if (window.navigator.languages && !locale) {
|
||||||
|
for (i=0; i<window.navigator.languages.length && !locale; i++) {
|
||||||
|
locale = isLocaleAvailable(window.navigator.languages[i], library_check);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.navigator.browserLanguage && !locale) {
|
||||||
|
locale = isLocaleAvailable(window.navigator.browserLanguage, library_check);
|
||||||
|
}
|
||||||
|
if (window.navigator.language && !locale) {
|
||||||
|
locale = isLocaleAvailable(window.navigator.language, library_check);
|
||||||
|
}
|
||||||
|
if (window.navigator.systemLanguage && !locale) {
|
||||||
|
locale = isLocaleAvailable(window.navigator.systemLanguage, library_check);
|
||||||
|
}
|
||||||
|
return locale || 'en';
|
||||||
|
};
|
||||||
|
|
||||||
|
const isMomentLocale = function (locale) {
|
||||||
|
if (!_.isString(locale)) { return false; }
|
||||||
|
return moment.locale() !== moment.locale(locale);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getLocale = function (preferred_locale, isSupportedByLibrary) {
|
||||||
|
if (_.isString(preferred_locale)) {
|
||||||
|
if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
|
||||||
|
return preferred_locale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _converse.detectLocale(isSupportedByLibrary) || 'en';
|
||||||
|
};
|
||||||
|
|
||||||
|
const isLocaleAvailable = function (locale, available) {
|
||||||
|
/* Check whether the locale or sub locale (e.g. en-US, en) is supported.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (String) locale - The locale to check for
|
||||||
|
* (Function) available - returns a boolean indicating whether the locale is supported
|
||||||
|
*/
|
||||||
|
if (available(locale)) {
|
||||||
|
return locale;
|
||||||
|
} else {
|
||||||
|
var sublocale = locale.split("-")[0];
|
||||||
|
if (sublocale !== locale && available(sublocale)) {
|
||||||
|
return sublocale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const isLocaleSupported = function (locale) {
|
||||||
|
/* Check whether the passed in locale is supported by Converse
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (String) locale: The given i18n locale
|
||||||
|
*/
|
||||||
|
if (!_.isString(locale)) { return false; }
|
||||||
|
return _.includes(_converse.locales, locale);
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchLocale = (locale, locale_url) =>
|
||||||
|
/* Fetch the translations for the given local at the given URL.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (String) locale: The given i18n locale
|
||||||
|
* (String) locale_url: The URL from which the translations should be fetched
|
||||||
|
*/
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
if (!isLocaleSupported(locale) || locale === 'en') {
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open(
|
||||||
|
'GET',
|
||||||
|
locale_url,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
xhr.setRequestHeader(
|
||||||
|
'Accept',
|
||||||
|
"application/json, text/javascript"
|
||||||
|
);
|
||||||
|
xhr.onload = function () {
|
||||||
|
if (xhr.status >= 200 && xhr.status < 400) {
|
||||||
|
resolve(new Jed(window.JSON.parse(xhr.responseText)));
|
||||||
|
} else {
|
||||||
|
xhr.onerror();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.onerror = function () {
|
||||||
|
reject(xhr.statusText);
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
|
// --------------------------
|
||||||
|
// END: Translation machinery
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
|
|
||||||
const PROMISES = [
|
const PROMISES = [
|
||||||
'initialized',
|
'initialized',
|
||||||
'cachedRoster',
|
'cachedRoster',
|
||||||
@ -234,9 +378,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Internationalization */
|
/* Internationalization */
|
||||||
moment.locale(utils.getLocale(settings.i18n, utils.isMomentLocale));
|
moment.locale(getLocale(settings.i18n, isMomentLocale));
|
||||||
_converse.locale = utils.getLocale(settings.i18n, utils.isLocaleSupported);
|
_converse.locale = getLocale(settings.i18n, isLocaleSupported);
|
||||||
const __ = _converse.__ = _.partial(utils.__, _converse);
|
const __ = _converse.__;
|
||||||
|
|
||||||
// XEP-0085 Chat states
|
// XEP-0085 Chat states
|
||||||
// http://xmpp.org/extensions/xep-0085.html
|
// http://xmpp.org/extensions/xep-0085.html
|
||||||
@ -273,6 +417,11 @@
|
|||||||
jid: undefined,
|
jid: undefined,
|
||||||
keepalive: true,
|
keepalive: true,
|
||||||
locales_url: '/locale/{{{locale}}}/LC_MESSAGES/converse.json',
|
locales_url: '/locale/{{{locale}}}/LC_MESSAGES/converse.json',
|
||||||
|
locales: [
|
||||||
|
'af', 'ca', 'de', 'es', 'en', 'fr', 'he',
|
||||||
|
'hu', 'id', 'it', 'ja', 'nb', 'nl',
|
||||||
|
'pl', 'pt_BR', 'ru', 'uk', 'zh'
|
||||||
|
],
|
||||||
message_carbons: true,
|
message_carbons: true,
|
||||||
message_storage: 'session',
|
message_storage: 'session',
|
||||||
password: undefined,
|
password: undefined,
|
||||||
@ -1884,15 +2033,15 @@
|
|||||||
finishInitialization();
|
finishInitialization();
|
||||||
return _converse;
|
return _converse;
|
||||||
} else {
|
} else {
|
||||||
utils.fetchLocale(
|
fetchLocale(
|
||||||
_converse.locale,
|
_converse.locale,
|
||||||
_converse.locales_url
|
_.template(_converse.locales_url)({'locale': _converse.locale})
|
||||||
).then((jed) => {
|
).then((jed) => {
|
||||||
_converse.jed = jed;
|
_converse.jed = jed;
|
||||||
finishInitialization();
|
finishInitialization();
|
||||||
}).catch((reason) => {
|
}).catch((reason) => {
|
||||||
finishInitialization();
|
finishInitialization();
|
||||||
_converse.log(reason, Strophe.LogLevel.FATAL);
|
_converse.log(reason, Strophe.LogLevel.ERROR);
|
||||||
});
|
});
|
||||||
return init_promise.promise;
|
return init_promise.promise;
|
||||||
}
|
}
|
||||||
|
@ -246,8 +246,19 @@
|
|||||||
* loaded by converse.js's plugin machinery.
|
* loaded by converse.js's plugin machinery.
|
||||||
*/
|
*/
|
||||||
const { _converse } = this,
|
const { _converse } = this,
|
||||||
{ __ } = _converse,
|
{ __ } = _converse;
|
||||||
{ ___ } = utils;
|
|
||||||
|
function ___ (str) {
|
||||||
|
/* 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 further below.
|
||||||
|
*/
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
// XXX: Inside plugins, all calls to the translation machinery
|
// XXX: Inside plugins, all calls to the translation machinery
|
||||||
// (e.g. utils.__) should only be done in the initialize function.
|
// (e.g. utils.__) should only be done in the initialize function.
|
||||||
// If called before, we won't know what language the user wants,
|
// If called before, we won't know what language the user wants,
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file specifies the language dependencies.
|
|
||||||
*
|
|
||||||
* Translations take up a lot of space and you are therefore advised to remove
|
|
||||||
* from here any languages that you don't need.
|
|
||||||
*
|
|
||||||
* See also src/moment_locales.js
|
|
||||||
*/
|
|
||||||
/*global define */
|
|
||||||
(function (root, factory) {
|
|
||||||
define(['jed',
|
|
||||||
'text!af',
|
|
||||||
'text!ca',
|
|
||||||
'text!de',
|
|
||||||
'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!uk',
|
|
||||||
'text!zh'
|
|
||||||
], function ($, Jed) {
|
|
||||||
root.locales = {
|
|
||||||
'en': {},
|
|
||||||
'af': arguments[1],
|
|
||||||
'ca': arguments[2],
|
|
||||||
'de': 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;
|
|
||||||
});
|
|
||||||
})(this);
|
|
127
src/utils.js
127
src/utils.js
@ -6,14 +6,13 @@
|
|||||||
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com>
|
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com>
|
||||||
// Licensed under the Mozilla Public License (MPLv2)
|
// Licensed under the Mozilla Public License (MPLv2)
|
||||||
//
|
//
|
||||||
/*global define, escape, locales, window, Jed */
|
/*global define, escape, window */
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"sizzle",
|
"sizzle",
|
||||||
"es6-promise",
|
"es6-promise",
|
||||||
"jquery.browser",
|
"jquery.browser",
|
||||||
"lodash.noconflict",
|
"lodash.noconflict",
|
||||||
"locales",
|
|
||||||
"moment_with_locales",
|
"moment_with_locales",
|
||||||
"strophe",
|
"strophe",
|
||||||
], factory);
|
], factory);
|
||||||
@ -22,12 +21,10 @@
|
|||||||
Promise,
|
Promise,
|
||||||
jQBrowser,
|
jQBrowser,
|
||||||
_,
|
_,
|
||||||
locales,
|
|
||||||
moment,
|
moment,
|
||||||
Strophe
|
Strophe
|
||||||
) {
|
) {
|
||||||
"use strict";
|
"use strict";
|
||||||
locales = locales || {};
|
|
||||||
const b64_sha1 = Strophe.SHA1.b64_sha1;
|
const b64_sha1 = Strophe.SHA1.b64_sha1;
|
||||||
Strophe = Strophe.Strophe;
|
Strophe = Strophe.Strophe;
|
||||||
|
|
||||||
@ -109,78 +106,6 @@
|
|||||||
|
|
||||||
var u = {};
|
var u = {};
|
||||||
|
|
||||||
// Translation machinery
|
|
||||||
// ---------------------
|
|
||||||
u.fetchLocale = (locale, locales_url) =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
if (!u.isLocaleSupported(locale) || locale === 'en') {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
xhr.open(
|
|
||||||
'GET',
|
|
||||||
_.template(locales_url)({'locale': locale}),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
xhr.setRequestHeader(
|
|
||||||
'Accept',
|
|
||||||
"application/json, text/javascript"
|
|
||||||
);
|
|
||||||
xhr.onload = function () {
|
|
||||||
if (xhr.status >= 200 && xhr.status < 400) {
|
|
||||||
resolve(new Jed(window.JSON.parse(xhr.responseText)));
|
|
||||||
} else {
|
|
||||||
xhr.onerror();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.onerror = function () {
|
|
||||||
reject(xhr.statusText);
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
});
|
|
||||||
|
|
||||||
u.__ = function (_converse, str) {
|
|
||||||
if (_.isUndefined(window.Jed)) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
if (_.isUndefined(_converse.jed)) {
|
|
||||||
return Jed.sprintf.apply(window.Jed, [].slice.call(arguments, 1));
|
|
||||||
}
|
|
||||||
var t = _converse.jed.translate(str);
|
|
||||||
if (arguments.length>1) {
|
|
||||||
return t.fetch.apply(t, [].slice.call(arguments, 2));
|
|
||||||
} else {
|
|
||||||
return t.fetch();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
u.___ = 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 in src/converse-muc.js
|
|
||||||
*/
|
|
||||||
return str;
|
|
||||||
};
|
|
||||||
|
|
||||||
u.isLocaleAvailable = function (locale, available) {
|
|
||||||
/* Check whether the locale or sub locale (e.g. en-US, en) is supported.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* (Function) available - returns a boolean indicating whether the locale is supported
|
|
||||||
*/
|
|
||||||
if (available(locale)) {
|
|
||||||
return locale;
|
|
||||||
} else {
|
|
||||||
var sublocale = locale.split("-")[0];
|
|
||||||
if (sublocale !== locale && available(sublocale)) {
|
|
||||||
return sublocale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
u.addHyperlinks = function (text) {
|
u.addHyperlinks = function (text) {
|
||||||
const list = text.match(URL_REGEX) || [];
|
const list = text.match(URL_REGEX) || [];
|
||||||
var links = [];
|
var links = [];
|
||||||
@ -480,56 +405,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
u.detectLocale = function (library_check) {
|
|
||||||
/* Determine which locale is supported by the user's system as well
|
|
||||||
* as by the relevant library (e.g. converse.js or moment.js).
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* (Function) library_check - returns a boolean indicating whether
|
|
||||||
* the locale is supported.
|
|
||||||
*/
|
|
||||||
var locale, i;
|
|
||||||
if (window.navigator.userLanguage) {
|
|
||||||
locale = u.isLocaleAvailable(window.navigator.userLanguage, library_check);
|
|
||||||
}
|
|
||||||
if (window.navigator.languages && !locale) {
|
|
||||||
for (i=0; i<window.navigator.languages.length && !locale; i++) {
|
|
||||||
locale = u.isLocaleAvailable(window.navigator.languages[i], library_check);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (window.navigator.browserLanguage && !locale) {
|
|
||||||
locale = u.isLocaleAvailable(window.navigator.browserLanguage, library_check);
|
|
||||||
}
|
|
||||||
if (window.navigator.language && !locale) {
|
|
||||||
locale = u.isLocaleAvailable(window.navigator.language, library_check);
|
|
||||||
}
|
|
||||||
if (window.navigator.systemLanguage && !locale) {
|
|
||||||
locale = u.isLocaleAvailable(window.navigator.systemLanguage, library_check);
|
|
||||||
}
|
|
||||||
return locale || 'en';
|
|
||||||
};
|
|
||||||
|
|
||||||
u.isLocaleSupported = function (locale) {
|
|
||||||
/* Check whether the passed in locale is supported by Converse */
|
|
||||||
if (!_.isString(locale)) { return false; }
|
|
||||||
return _.includes(_.keys(locales || {}), locale);
|
|
||||||
};
|
|
||||||
|
|
||||||
u.isMomentLocale = function (locale) {
|
|
||||||
if (!_.isString(locale)) { return false; }
|
|
||||||
return moment.locale() !== moment.locale(locale);
|
|
||||||
};
|
|
||||||
|
|
||||||
u.getLocale = function (preferred_locale, isSupportedByLibrary) {
|
|
||||||
if (_.isString(preferred_locale)) {
|
|
||||||
if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
|
|
||||||
return preferred_locale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return u.detectLocale(isSupportedByLibrary) || 'en';
|
|
||||||
};
|
|
||||||
|
|
||||||
u.isOfType = function (type, item) {
|
u.isOfType = function (type, item) {
|
||||||
return item.get('type') == type;
|
return item.get('type') == type;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user