mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
Moved settings.js to ts.
This commit is contained in:
parent
4f53142d7f
commit
71c74bc633
40 changed files with 217 additions and 205 deletions
|
@ -9,7 +9,7 @@ const path = require('path');
|
|||
const _ = require('underscore');
|
||||
const pluginDefs = require('../../static/js/pluginfw/plugin_defs.js');
|
||||
const existsSync = require('../utils/path_exists');
|
||||
const settings = require('../utils/Settings');
|
||||
import {customLocaleStrings, maxAge, root} from '../utils/Settings';
|
||||
|
||||
// returns all existing messages merged together and grouped by langcode
|
||||
// {es: {"foo": "string"}, en:...}
|
||||
|
@ -40,7 +40,7 @@ const getAllLocales = () => {
|
|||
};
|
||||
|
||||
// add core supported languages first
|
||||
extractLangs(path.join(settings.root, 'src/locales'));
|
||||
extractLangs(path.join(root, 'src/locales'));
|
||||
|
||||
// add plugins languages (if any)
|
||||
for (const {package: {path: pluginPath}} of Object.values<I18nPluginDefs>(pluginDefs.plugins)) {
|
||||
|
@ -71,9 +71,9 @@ const getAllLocales = () => {
|
|||
const wrongFormatErr = Error(
|
||||
'customLocaleStrings in wrong format. See documentation ' +
|
||||
'for Customization for Administrators, under Localization.');
|
||||
if (settings.customLocaleStrings) {
|
||||
if (typeof settings.customLocaleStrings !== 'object') throw wrongFormatErr;
|
||||
_.each(settings.customLocaleStrings, (overrides:MapArrayType<string> , langcode:string) => {
|
||||
if (customLocaleStrings) {
|
||||
if (typeof customLocaleStrings !== 'object') throw wrongFormatErr;
|
||||
_.each(customLocaleStrings, (overrides:MapArrayType<string> , langcode:string) => {
|
||||
if (typeof overrides !== 'object') throw wrongFormatErr;
|
||||
_.each(overrides, (localeString:string|object, key:string) => {
|
||||
if (typeof localeString !== 'string') throw wrongFormatErr;
|
||||
|
@ -133,7 +133,7 @@ exports.expressPreSession = async (hookName:string, {app}:any) => {
|
|||
// works with /locale/en and /locale/en.json requests
|
||||
const locale = req.params.locale.split('.')[0];
|
||||
if (Object.prototype.hasOwnProperty.call(exports.availableLangs, locale)) {
|
||||
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
|
||||
res.setHeader('Cache-Control', `public, max-age=${maxAge}`);
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`);
|
||||
} else {
|
||||
|
@ -142,7 +142,7 @@ exports.expressPreSession = async (hookName:string, {app}:any) => {
|
|||
});
|
||||
|
||||
app.get('/locales.json', (req: any, res:any) => {
|
||||
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
|
||||
res.setHeader('Cache-Control', `public, max-age=${maxAge}`);
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
res.send(localeIndex);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue