Merge branch 'i18n-momentjs' of https://github.com/thierrytiti/converse.js into thierrytiti-i18n-momentjs
Conflicts: converse.js Also refactored the code to adhere to the style guide.
This commit is contained in:
commit
e999f2c6df
72
converse.js
72
converse.js
|
@ -240,41 +240,63 @@
|
|||
var OPENED = 'opened';
|
||||
var CLOSED = 'closed';
|
||||
|
||||
// Translation machinery
|
||||
// ---------------------
|
||||
this.isAvailableLocale = function (locale) {
|
||||
if (locales[locale]) {
|
||||
return locales[locale];
|
||||
// Detect support for the user's locale
|
||||
// ------------------------------------
|
||||
this.isConverseLocale = function (locale) { return typeof locales[locale] !== "undefined"; };
|
||||
this.isMomentLocale = function (locale) { return moment.locale() != moment.locale(locale); };
|
||||
|
||||
this.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 && locales[sublocale]) {
|
||||
return locales[sublocale];
|
||||
if (sublocale != locale && available(sublocale)) {
|
||||
return sublocale;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.detectLocale = function () {
|
||||
var ret, i;
|
||||
this.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) {
|
||||
return this.isAvailableLocale(window.navigator.userLanguage);
|
||||
} else if (window.navigator.languages) {
|
||||
for (i=0; i < window.navigator.languages.length && !ret; i++) {
|
||||
ret = this.isAvailableLocale(window.navigator.languages[i]);
|
||||
}
|
||||
return ret || locales.en;
|
||||
} else if (window.navigator.browserLanguage) {
|
||||
return this.isAvailableLocale(window.navigator.browserLanguage);
|
||||
} else if (window.navigator.language) {
|
||||
return this.isAvailableLocale(window.navigator.language);
|
||||
} else if (window.navigator.systemLanguage) {
|
||||
return this.isAvailableLocale(window.navigator.systemLanguage);
|
||||
} else {
|
||||
return locales.en;
|
||||
locale = this.isLocaleAvailable(window.navigator.userLanguage, library_check);
|
||||
}
|
||||
if (window.navigator.languages && !locale) {
|
||||
for (i=0; i<window.navigator.languages.length && !locale; i++) {
|
||||
locale = this.isLocaleAvailable(window.navigator.languages[i], library_check);
|
||||
}
|
||||
}
|
||||
if (window.navigator.browserLanguage && !locale) {
|
||||
locale = this.isLocaleAvailable(window.navigator.browserLanguage, library_check);
|
||||
}
|
||||
if (window.navigator.language && !locale) {
|
||||
locale = this.isLocaleAvailable(window.navigator.language, library_check);
|
||||
}
|
||||
if (window.navigator.systemLanguage && !locale) {
|
||||
locale = this.isLocaleAvailable(window.navigator.systemLanguage, library_check);
|
||||
}
|
||||
return locale || locales.en;
|
||||
};
|
||||
this.i18n = settings.i18n ? settings.i18n : this.detectLocale();
|
||||
|
||||
if (!moment.locale) { //moment.lang is deprecated after 2.8.1, use moment.locale instead
|
||||
moment.locale = moment.lang;
|
||||
}
|
||||
moment.locale(this.detectLocale(this.isMomentLocale));
|
||||
this.i18n = settings.i18n ? settings.i18n : locales[this.detectLocale(this.isConverseLocale)];
|
||||
|
||||
// Translation machinery
|
||||
// ---------------------
|
||||
var __ = $.proxy(utils.__, this);
|
||||
var ___ = utils.___;
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ Changelog
|
|||
* #401 Updated French translation [thierrytiti]
|
||||
* #404 CSS fix: position and width of the div #conversejs [thierrytiti]
|
||||
* #407 CSS: Fonts Path: editabable $font-path via sass/variables.scss [thierrytiti]
|
||||
* #408 MUC: missing toggle call handler and updated documentation about call. [thierrytiti]
|
||||
* #408 MUC: missing toggle call handler and updated documentation about call [thierrytiti]
|
||||
* #413 Auto-detect user's locale to show date and time in the right format [thierrytiti]
|
||||
* #415 closeAllChatBoxes is giving ReferenceError when 2 chats are open [nevcos, jcbrand]
|
||||
* #416 Add icon for XA status [thierrytiti]
|
||||
* #418 Logging out with `auto_reconnect=true` causes reconnection retries [jcbrand]
|
||||
|
@ -26,6 +27,8 @@ Changelog
|
|||
* Refactored the plugin architecture. Add `overrides` convention for
|
||||
automatically overriding converse.js's methods and Backbone views and models. [jcbrand]
|
||||
* Decouple automatic away and XEP-0352 support. [jcbrand]
|
||||
* CSS: Fonts Path: editabable $font-path via sass/variables.scss [thierrytiti]
|
||||
* Add offline pretty status to enable translation [thierrytiti]
|
||||
|
||||
0.9.3 (2015-05-01)
|
||||
------------------
|
||||
|
|
2
main.js
2
main.js
|
@ -26,7 +26,7 @@ require.config({
|
|||
"jquery-private": "src/jquery-private",
|
||||
"jquery.browser": "components/jquery.browser/dist/jquery.browser",
|
||||
"jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website
|
||||
"moment": "components/momentjs/moment",
|
||||
"moment": "components/momentjs/min/moment-with-langs",
|
||||
"strophe-base64": "components/strophejs/src/base64",
|
||||
"strophe-bosh": "components/strophejs/src/bosh",
|
||||
"strophe-core": "components/strophejs/src/core",
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<script type="text/javascript" src="components/backbone//backbone.js"></script>
|
||||
<script type="text/javascript" src="components/backbone.browserStorage/backbone.browserStorage.js"></script>
|
||||
<script type="text/javascript" src="components/backbone.overview/backbone.overview.js"></script>
|
||||
<script type="text/javascript" src="components/momentjs/moment.js"></script>
|
||||
<script type="text/javascript" src="components/momentjs/min/moment-with-langs.js"></script>
|
||||
<script type="text/javascript" src="components/jquery.browser/dist/jquery.browser.js"></script>
|
||||
<script type="text/javascript" src="components/typeahead.js/index.js"></script>
|
||||
<script type="text/javascript" src="components/jed/jed.js"></script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user