remade localization system once again
- new localization system: fast, dynamic, way more organized - localization strings are WAY more descriptive - it's now easier to add support for other languages (just one loc file instead of five) - localization now falls back to english if localized string isnt available - got rid of all static language selectors (probably) - slightly updated english and russian strings - miscellaneous settings items have been bundled together and moved to the bottom, cause they're used the least - bottom links should no longer touch the popup border on overflow - rearranged popup order in the rendered page - bumped version up to 2.2.5 if you see strings that are like this: !!EXAMPLE!! or withoutspace please file an issue on github
This commit is contained in:
@@ -9,10 +9,10 @@ import { shortCommit } from "./modules/sub/currentCommit.js";
|
||||
import { appName, genericUserAgent, version, internetExplorerRedirect } from "./modules/config.js";
|
||||
import { getJSON } from "./modules/api.js";
|
||||
import renderPage from "./modules/pageRender.js";
|
||||
import { apiJSON } from "./modules/sub/utils.js";
|
||||
import loc from "./modules/sub/i18n.js";
|
||||
import { apiJSON, languageCode } from "./modules/sub/utils.js";
|
||||
import { Bright, Cyan } from "./modules/sub/consoleText.js";
|
||||
import stream from "./modules/stream/stream.js";
|
||||
import loc from "./localization/manager.js";
|
||||
|
||||
const commitHash = shortCommit();
|
||||
const app = express();
|
||||
@@ -26,7 +26,7 @@ if (fs.existsSync('./.env')) {
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
handler: (req, res, next, opt) => {
|
||||
res.status(429).json({ "status": "error", "text": loc('en', 'apiError', 'rateLimit') });
|
||||
res.status(429).json({ "status": "error", "text": loc(languageCode(req), 'ErrorRateLimit') });
|
||||
}
|
||||
})
|
||||
const apiLimiterStream = rateLimit({
|
||||
@@ -35,7 +35,7 @@ if (fs.existsSync('./.env')) {
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
handler: (req, res, next, opt) => {
|
||||
res.status(429).json({ "status": "error", "text": loc('en', 'apiError', 'rateLimit') });
|
||||
res.status(429).json({ "status": "error", "text": loc(languageCode(req), 'ErrorRateLimit') });
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,13 +61,13 @@ if (fs.existsSync('./.env')) {
|
||||
let j = await getJSON(
|
||||
req.query.url.trim(),
|
||||
req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip,
|
||||
req.header('Accept-Language') ? req.header('Accept-Language').slice(0, 2) : "en",
|
||||
languageCode(req),
|
||||
req.query.format ? req.query.format.slice(0, 5) : "mp4",
|
||||
req.query.quality ? req.query.quality.slice(0, 3) : "max"
|
||||
)
|
||||
res.status(j.status).json(j.body);
|
||||
} else {
|
||||
let j = apiJSON(3, { t: loc('en', 'apiError', 'noURL', process.env.selfURL) })
|
||||
let j = apiJSON(3, { t: loc(languageCode(req), 'ErrorNoLink', process.env.selfURL) })
|
||||
res.status(j.status).json(j.body);
|
||||
}
|
||||
break;
|
||||
@@ -78,12 +78,12 @@ if (fs.existsSync('./.env')) {
|
||||
let ip = req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip
|
||||
stream(res, ip, req.query.t, req.query.h, req.query.e);
|
||||
} else {
|
||||
let j = apiJSON(0, { t: loc('en', 'apiError', 'noStreamID') })
|
||||
let j = apiJSON(0, { t: loc(languageCode(req), 'ErrorNoStreamID') })
|
||||
res.status(j.status).json(j.body);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
let j = apiJSON(0, { t: loc('en', 'apiError', 'noType') })
|
||||
let j = apiJSON(0, { t: loc(languageCode(req), 'ErrorNoType') })
|
||||
res.status(j.status).json(j.body);
|
||||
break;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ if (fs.existsSync('./.env')) {
|
||||
res.send(renderPage({
|
||||
"hash": commitHash,
|
||||
"type": "default",
|
||||
"lang": req.header('Accept-Language') ? req.header('Accept-Language').slice(0, 2) : "en",
|
||||
"lang": languageCode(req),
|
||||
"useragent": req.header('user-agent') ? req.header('user-agent') : genericUserAgent
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user