From c75e4035b6be10b2af7b950bece1a4a87b815d0a Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 17 Apr 2019 14:54:01 +0200 Subject: [PATCH] Make the list of available languages for CryptPad configurable --- customize.dist/messages.js | 22 ++++++++++++++++++++-- www/common/application_config_internal.js | 12 +++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/customize.dist/messages.js b/customize.dist/messages.js index 5fa0c6389..833e9cd19 100755 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -43,13 +43,31 @@ require.config({ } }); -var req = ['/common/common-util.js', '/customize/translations/messages.js']; +var req = [ + '/common/common-util.js', + '/customize/application_config.js', + '/customize/translations/messages.js' +]; if (language && map[language]) { req.push('/customize/translations/messages.' + language + '.js'); } -define(req, function(Util, Default, Language) { +define(req, function(Util, AppConfig, Default, Language) { map.en = 'English'; var defaultLanguage = 'en'; + if (AppConfig.availableLanguages) { + if (AppConfig.availableLanguages.indexOf(language) === -1) { + language = defaultLanguage; + Language = Default; + localStorage.setItem(LS_LANG, language); + } + Object.keys(map).forEach(function (l) { + if (l === defaultLanguage) { return; } + if (AppConfig.availableLanguages.indexOf(l) === -1) { + delete map[l]; + } + }); + } + Util.extend(messages, Default); if (Language && language !== defaultLanguage) { // Add the translated keys to the returned object diff --git a/www/common/application_config_internal.js b/www/common/application_config_internal.js index c6f2a04d6..513d64924 100644 --- a/www/common/application_config_internal.js +++ b/www/common/application_config_internal.js @@ -22,13 +22,23 @@ define(function() { */ config.registeredOnlyTypes = ['file', 'contacts', 'oodoc', 'ooslide', 'sheet']; + /* CryptPad is available is multiple languages, but only English and French are maintained + * by the developers. The other languages may be outdated, and any missing string for a langauge + * will use the english version instead. You can customize the langauges you want to be available + * on your instance by removing them from the following list. + * An empty list will load all available languages for CryptPad. The list of available languages + * can be found at the top of the file `/customize.dist/messages.js`. The list should only + * contain languages code ('en', 'fr', 'de', 'pt-br', etc.), not their full name. + */ + //config.availableLanguages = ['en', 'fr', 'de']; + + /* Cryptpad apps use a common API to display notifications to users * by default, notifications are hidden after 5 seconds * You can change their duration here (measured in milliseconds) */ config.notificationTimeout = 5000; config.disableUserlistNotifications = false; - config.hideLoadingScreenTips = false; config.enablePinning = true;