完善翻译

This commit is contained in:
undefined committed 2020-06-20 12:05:44 +08:00
1 parent 7d3bdc2dd1
commit 2d3cee7753
13 files changed
+1308 -1280

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
"files.autoSave": "onFocusChange",
"files.encoding": "utf8",
"files.eol": "\n",
"editor.detectIndentation": false,
"editor.detectIndentation": true,
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.renderWhitespace": "boundary"
+4 -2
View File
@@ -103,7 +103,6 @@ class HomeSecurityHandler extends Handler {
async get() {
// TODO(iceboy): pagination? or limit session count for uid?
const sessions = await token.getSessionListByUid(this.user._id);
const parsed = [];
for (const session of sessions) {
session.isCurrent = session._id === this.session._id;
session._id = md5(session._id);
@@ -111,7 +110,8 @@ class HomeSecurityHandler extends Handler {
if (geoip) session.updateGeoip = geoip.lookup(session.updateIp || session.createIp);
}
this.response.template = 'home_security.html';
this.response.body = { sessions: parsed, geoipProvider: (geoip || {}).provider };
this.response.body = { sessions, geoipProvider: (geoip || {}).provider };
if (useragent) this.response.body.icon = useragent.icon;
}
async postChangePassword({ current, password, verifyPassword }) {
@@ -160,6 +160,8 @@ class HomeSettingsHandler extends Handler {
}
async get({ category }) {
// eslint-disable-next-line prefer-destructuring
category = category[0]; // Category would be splitted into array
const path = [
['Hydro', 'homepage'],
[`home_${category}`, null],
+2 -2
View File
@@ -127,9 +127,9 @@ class RecordMainConnectionHandler extends RecordConnectionHandler {
// eslint-disable-next-line prefer-const
let [udoc, pdoc] = await Promise.all([
user.getById(this.domainId, rdoc.uid),
problem.get(this.domainId, rdoc.pid),
problem.get(this.domainId, rdoc.pid, null, false),
]);
if (pdoc.hidden && !this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) pdoc = null;
if (pdoc && pdoc.hidden && !this.user.hasPerm(PERM_VIEW_PROBLEM_HIDDEN)) pdoc = null;
this.send({ html: await this.renderHTML('record_main_tr.html', { rdoc, udoc, pdoc }) });
}
}
+4 -2
View File
@@ -23,8 +23,10 @@ const Mark = require('markdown-it-mark');
// :::warn This page requires javascript. :::
// :::record-pass Accepted :::
const Container = require('markdown-it-container');
// FIXME doesn't work for webpack
const Anchor = require('markdown-it-anchor');
let Anchor = require('markdown-it-anchor');
// For webpack
if (Anchor.default) Anchor = Anchor.default;
const TOC = require('markdown-it-table-of-contents');
require('prismjs/components/index');
+7 -5
View File
@@ -1,9 +1,11 @@
const browser = require('detect-browser');
function get(str) {
const ua = browser.parseUserAgent(str);
console.log(ua);
return ua;
function parse(str) {
return browser.parseUserAgent(str);
}
global.Hydro.lib.useragent = module.exports = get;
function icon(str) {
return str.split(' ')[0].toLowerCase();
}
global.Hydro.lib.useragent = module.exports = { parse, icon };
+27 -2
View File
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const os = require('os');
const cluster = require('cluster');
const _ = require('lodash');
const { ObjectID } = require('bson');
const Koa = require('koa');
const yaml = require('js-yaml');
@@ -32,7 +32,10 @@ const _validateObjectId = (id, key) => {
throw new ValidationError(key);
};
const _bool = (val) => !!val;
const _splitAndTrim = (val) => val.split(',').map((i) => i.trim());
const _splitAndTrim = (val) => {
const t = val.split(',').map((i) => i.trim().split('+'));
return _.flatten(t);
};
const _date = (val) => {
const d = val.split('-');
assert(d.length === 3);
@@ -412,10 +415,31 @@ class ConnectionHandler {
for (const i in p) this.request.params[p[i][0]] = decodeURIComponent(p[i][1]);
}
url(name, kwargs = {}) { // eslint-disable-line class-methods-use-this
let res = '#';
try {
delete kwargs.__keywords;
if (this.args.domainId !== 'system') {
name += '_with_domainId';
kwargs.domainId = kwargs.domainId || this.args.domainId;
}
const { anchor, query } = kwargs;
delete kwargs.anchor;
delete kwargs.query;
if (query) res = router.url(name, kwargs, { query });
else res = router.url(name, kwargs);
if (anchor) return `${res}#${anchor}`;
} catch (e) {
console.error(e.message);
}
return res;
}
async renderHTML(name, context) {
this.hasPerm = (perm) => this.user.hasPerm(perm);
const res = await template.render(name, Object.assign(context, {
handler: this,
url: (...args) => this.url(...args),
_: (str) => (str ? str.toString().translate(this.user.viewLang || this.session.viewLang) : ''),
user: this.user,
}));
@@ -450,6 +474,7 @@ function Connection(name, prefix, RouteConnHandler, permission) {
const h = new RouteConnHandler(conn);
try {
const args = { domainId: 'system', ...h.request.params };
h.args = args;
if (h.___prepare) await h.___prepare(args);
if (permission) h.checkPerm(permission);
let checking = '';
+49 -50
View File
@@ -1,83 +1,82 @@
#English
---
contest_main: Contest
__langname: English
Can be Extended For: Extension
contest_create: Contest Create
contest_edit: Contest Edit
contest_scoreboard: Scoreboard
contest_detail_problem_submit: Submit Contest Problem
contest_edit: Contest Edit
contest_main: Contest
contest_scoreboard: Scoreboard
discussion_create: Create Discussion
discussion_edit: Discussion Edit
discussion_main: Discussion
discussion_node: Discussion
display_name: Display Name
domain_main: Main
fs_upload: File Upload
home_account: Account Settings
home_domain_account: Profile @ Domain
home_preference: Preference
home_messages: Messages
home_security: Security
home_domain_create: Create Domain
home_domain: My Domains
homework_main: Homework
home_file: My Files
home_messages: Messages
home_preference: Preference
home_security: Security
homework_create: Homework Create
homework_edit: Homework Edit
homework_scoreboard: Scoreboard
homework_detail_problem_submit: Submit Homework Problem
homework_edit: Homework Edit
homework_main: Homework
homework_scoreboard: Scoreboard
judge_playground: Judge Playground
main: Home
manage_dashboard: Dashboard
manage_discussion: Discussion Nodes
manage_edit: Edit Info
manage_join_applications: Join Applications
manage_module: Module Management
manage_permission: System Permission
manage_role: System Role
manage_setting: System Settings
manage_user: System User
manage: System Manage
no_translation_warn: <blockquote class="warn">This part of content is under translation.</blockquote>
page.problem_detail.sidebar.show_category: Click to Show
page.training_detail.invalid_when_not_enrolled: You cannot view problem details unless enrolled.
pager_first: « First
pager_last: Last »
pager_next: Next ›
pager_previous: ‹ Previous
perm_contest: Contests
perm_discussion: Discussions
perm_general: General
perm_problem_solution: Problem Solutions
perm_problem: Problems
perm_record: Records
perm_training: Trainings
problem_create: Problem Create
problem_edit: Problem Edit
problem_main: Problem Set
problem_solution: Problem Solution
problem_submit: Problem Submit
problem_settings: Problem Settings
problem_solution: Problem Solution
problem_statistics: Problem Statistics
problem_submit: Problem Submit
problem-category-delim: '|'
problem-subcategory-delim: ', '
record_detail: Record Detail
record_main: Judging Queue
setting_customize: Customize
setting_display: Display Preference
setting_function: Function
setting_info_domain: Personal Info
setting_info: Personal Info
setting_preference: Preference
setting_privacy: Privacy
setting_customize: Customize
training_main: Training
training_edit: Training Edit
setting_usage: Usage Preference
timeago_locale: en
training_create: Training Create
training_edit: Training Edit
training_main: Training
user_detail: User Detail
user_login: Login
user_logout: Logout
user_lostpass: Lost Password
user_register: Register
home_domain_create: Create Domain
domain_main: Main
manage: System Manage
manage_dashboard: Dashboard
manage_discussion: Discussion Nodes
manage_edit: Edit Info
manage_join_applications: Join Applications
manage_role: System Role
manage_user: System User
manage_permission: System Permission
manage_module: Module Management
manage_setting: System Settings
timeago_locale: en
perm_general: General
perm_problem: Problems
perm_record: Records
perm_problem_solution: Problem Solutions
perm_discussion: Discussions
perm_contest: Contests
perm_training: Trainings
discussion_edit: Discussion Edit
wiki_help: Help
no_translation_warn: <blockquote class="warn">This part of content is under translation.</blockquote>
problem-category-delim: '|'
problem-subcategory-delim: ', '
setting_display: Display Preference
setting_usage: Usage Preference
home_file: My Files
fs_upload: File Upload
page.training_detail.invalid_when_not_enrolled: You cannot view problem details unless enrolled.
page.problem_detail.sidebar.show_category: Click to Show
setting_info_domain: Personal Info
display_name: Display Name
Can be Extended For: Extension
wiki_help: Help
+718 -714
View File
File diff suppressed because it is too large. Load diff
+489 -493
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -48,10 +48,10 @@ class PasteCreateHandler extends Handler {
}
async function apply() {
Route('paste', '/paste', PasteMainHandler);
Route('pastebin', '/paste', PasteMainHandler);
Route('paste_create', '/paste/create', PasteCreateHandler);
Route('paste_show', '/paste/:docId', PasteShowHandler);
nav('paste', null, 'paste', PERM_LOGGEDIN);
nav('pastebin', null, 'pastebin', PERM_LOGGEDIN);
}
global.Hydro.handler.pastebin = module.exports = apply;
+2 -2
View File
@@ -90,13 +90,13 @@
<li class="sessionlist__item">
<div class="media">
<div class="media__left medium">
<span class="sessionlist__icon icon icon-platform--{{ session.updateUa.icon }}"></span>
<span class="sessionlist__icon icon icon-platform--{{ icon(session.updateUa.os) }}"></span>
</div>
<div class="media__body medium typo">
<p>{{ _('Last Update At') }}: {{ datetimeSpan(session.updateAt)|safe }}</p>
<p>{{ _('Location') }}: {{ _(session.updateGeoip) }} ({{ session.updateIp }})</p>
<p>{{ _('Operating System') }}: {{ session.updateUa.os }}</p>
<p>{{ _('Browser') }}: {{ session.updateUa.browser }}</p>
<p>{{ _('Browser') }}: {{ session.updateUa.name }} {{ session.updateUa.version }}</p>
<!-- {{ _('User-Agent') }}: {{ session['update_ua']['str'] }} -->
{% if session.isCurrent %}
<p class="sessionlist__current-session"><span class="icon icon-check"></span> {{ _('This is the current session') }}</p>
-3
View File
@@ -1,7 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import fs from 'fs';
import webpack from 'webpack';
import root from './utils/root';
import webpackConfig from './config/webpack';
export default function ({ watch, production }) {
@@ -13,7 +11,6 @@ export default function ({ watch, production }) {
if (err.details) console.error(err.details);
process.exit(1);
}
fs.writeFileSync(root('./.webpackStats.json'), JSON.stringify(stats.toJson(), null, 2));
if (!watch && stats.hasErrors()) process.exitCode = 1;
}
+3 -2
View File
@@ -4,7 +4,8 @@ import { AutoloadPage } from 'vj/misc/PageLoader';
import i18n from 'vj/utils/i18n';
timeago.register(i18n('timeago_locale'));
const locales = require.context('timeago.js/lib/lang', false, /\.js$/);
timeago.register(i18n('timeago_locale'), locales(`./${i18n('timeago_locale')}.js`).default);
function runRelativeTime($container) {
$container.find('span.time.relative[data-timestamp]').get().forEach((element) => {
@@ -15,7 +16,7 @@ function runRelativeTime($container) {
$element.attr('data-tooltip', $element.text());
$element.attr('datetime', ($element.attr('data-timestamp') || 0) * 1000);
$element.attr('data-has-timeago', '1');
timeago.render(element);
timeago.render(element, i18n('timeago_locale'));
});
}