From 9cfdbe3aa909962c5f3806d62653bf71e73ea214 Mon Sep 17 00:00:00 2001 From: Macesuted <57275149+Macesuted@users.noreply.github.com> Date: Fri, 26 Mar 2021 18:01:18 +0800 Subject: [PATCH] core: fix import-syzoj (#61) Co-authored-by: Macesuted --- packages/hydrooj/src/handler/import.syzoj.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/src/handler/import.syzoj.ts b/packages/hydrooj/src/handler/import.syzoj.ts index 065de5aff..df4f97be6 100644 --- a/packages/hydrooj/src/handler/import.syzoj.ts +++ b/packages/hydrooj/src/handler/import.syzoj.ts @@ -132,11 +132,14 @@ class ProblemImportSYZOJHandler extends Handler { protocol: string, host: string, pid: string | number, wait = false, ) { + let tagsOfLocale = this.user.viewLang || this.session.viewLang; + if (tagsOfLocale === 'en') tagsOfLocale = 'en_US'; + else tagsOfLocale = 'zh_CN'; const result = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/getProblem`) .send({ displayId: +pid, localizedContentsOfAllLocales: true, - tagsOfLocale: this.user.viewLang || this.session.viewLang, + tagsOfLocale, samples: true, testData: true, additionalFiles: true, @@ -154,7 +157,10 @@ class ProblemImportSYZOJHandler extends Handler { delete section.sampleId; } } - content[c.locale] = sections; + let locale = c.locale; + if (locale === 'en_US') locale = 'en'; + else if (locale === 'zh_CN') locale = 'zh'; + content[locale] = sections; } const tags = result.body.tagsOfLocale.map((node) => node.name); const title = [