1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-10-31 23:31:48 +09:00

Fallback en-US

This commit is contained in:
syuilo 2019-02-02 16:16:31 +09:00
parent d692d531d1
commit 2a50997a75
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -19,6 +19,14 @@ import endpoints from '../api/endpoints';
const locales = require('../../../locales');
import * as nestedProperty from 'nested-property';
function getLang(lang: string): string {
if (['en-US', 'ja-JP'].includes(lang)) {
return lang;
} else {
return 'en-US';
}
}
async function genVars(lang: string): Promise<{ [key: string]: any }> {
const vars = {} as { [key: string]: any };
@ -167,7 +175,7 @@ router.get('/assets/*', async ctx => {
});
router.get('/*/api/endpoints/*', async ctx => {
const lang = ctx.params[0];
const lang = getLang(ctx.params[0]);
const name = ctx.params[1];
const ep = endpoints.find(e => e.name === name);
@ -194,7 +202,7 @@ router.get('/*/api/endpoints/*', async ctx => {
});
router.get('/*/api/entities/*', async ctx => {
const lang = ctx.params[0];
const lang = getLang(ctx.params[0]);
const entity = ctx.params[1];
const x = yaml.safeLoad(fs.readFileSync(path.resolve(`${__dirname}/../../../src/docs/api/entities/${entity}.yaml`), 'utf-8'));
@ -211,7 +219,7 @@ router.get('/*/api/entities/*', async ctx => {
});
router.get('/*/*', async ctx => {
const lang = ctx.params[0];
const lang = getLang(ctx.params[0]);
const doc = ctx.params[1];
showdown.extension('urlExtension', () => ({