Skip to content

Commit

Permalink
Merge pull request #55 from putianyi889/patch-40
Browse files Browse the repository at this point in the history
实装波兰语本地化
  • Loading branch information
eee555 authored Jun 30, 2024
2 parents 4b9a230 + 04da0d2 commit e2951f8
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 13 deletions.
2 changes: 1 addition & 1 deletion back_end/saolei/saolei/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

ROOT_URLCONF = "saolei.urls"

RATELIMIT_VIEW = "utils.ratelimited"
RATELIMIT_VIEW = "utils.response.ratelimited_error"

TEMPLATES = [
{
Expand Down
4 changes: 4 additions & 0 deletions back_end/saolei/utils/response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.http import HttpResponse

def ratelimited_error(request, exception):
return HttpResponse(status=429)
6 changes: 4 additions & 2 deletions front_end/src/components/LanguagePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const options = [
{ lang: "zh-cn", text: "简体中文" },
{ lang: "en", text: "English" },
{ lang: "de", text: "name" },
{ lang: "pl", text: "polski"},
{ lang: "dev", text: "dev" },
];
Expand All @@ -39,8 +40,9 @@ const changeLanguage = (value: any) => {

<style lang="less" scoped>
.icon {
margin-top: v-bind("local.menu_height / 4 + 'px'");
margin-bottom: v-bind("local.menu_height / 4 + 'px'");
margin-top: v-bind("(local.menu_height - local.menu_font_size) / 2 + 'px'");
min-width: v-bind("local.menu_font_size + 'px'");
height: v-bind("local.menu_font_size + 'px'");
cursor: pointer;
}
</style>
77 changes: 71 additions & 6 deletions front_end/src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,71 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
// 嵌套配置示例 TODO 删除嵌套配置示例
name: string,
common: {
action: {
getSoftware: string,
getUserProfile: string,
setUserProfile: string,
uploadFile: string,
videoQuery: string,
},
hide: string,
level: {
b: string,
i: string,
e: string,
},
mode: {
standard: string,
noFlag: string,
noGuess: string,
recursive: string
std: string,
nf: string,
ng: string,
dg: string,
}
msg: {
actionFail: string,
actionSuccess: string,
agreeTAC: string,
confirmPasswordFail: string,
connectionFail: string,
emailCodeSent: string,
emptyEmail: string,
emptyEmailCode: string,
emptyPassword: string,
emptyUsername: string,
fileTooLarge: string,
invalidEmail: string,
invalidEmailCode: string,
invalidPassword: string,
invalidUsername: string,
logoutFail: string,
logoutSuccess: string,
realNameRequired: string,
},
prop: {
action: string,
designator: string,
fileName: string,
is: string,
op: string,
level: string,
realName: string,
sex: string,
status: string,
time: string,
timems: string,
upload_time: string,
}
response: {
OK: '',
BadRequest: string,
Forbidden: string,
InternalServerError: string,
NotFound: string,
PayloadTooLarge: string,
TooManyRequests: string,
UnsupportedMediaType: string,
},
show: string,
toDo: string,
},
forgetPassword: {
title: string,
Expand All @@ -38,7 +84,8 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
emailCode: string,
password: string,
confirmPassword: string,
confirm: string
confirm: string,
success: string,
},
login: {
title: string,
Expand All @@ -60,6 +107,7 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
login: string,
logout: string,
register: string,
setting: string,
downloads: string,
links: string,
team: string
Expand All @@ -74,6 +122,13 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
confirmChange: string,
cancelChange: string,
designator: string,
msg: {
avatarChange: string,
avatarFormat: string,
avatarFilesize: string,
realnameChange: string,
signatureChange: string,
},
records: {
title: string,
modeRecord: string
Expand Down Expand Up @@ -110,6 +165,16 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
confirmPassword: string,
agreeTo: string,
termsAndConditions: string,
confirm: string
confirm: string,
},
setting: {
appearance: string,
darkMode: string,
languageSwitch: string,
menuFontSize: string,
menuHeight: string,
menuLayout: string,
menuLayoutAbstract: string,
menuLayoutDefault: string,
},
}
2 changes: 2 additions & 0 deletions front_end/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dev } from '@/i18n/locales/dev'
import { zhCn } from '@/i18n/locales/zh-cn'
import { de } from '@/i18n/locales/de'
import { en } from './locales/en'
import { pl } from './locales/pl'

/**
* 获取所有语言
Expand All @@ -13,6 +14,7 @@ function getMessages (): Record<string, any> {
messages[zhCn.local] = zhCn
messages[de.local] = de
messages[en.local] = en
messages[pl.local] = pl
return messages
}

Expand Down
54 changes: 50 additions & 4 deletions front_end/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { LocaleConfig } from '@/i18n/config'

export const en = {
local: 'en',
name: 'English',
common: {
action: {
getSoftware: 'fetch video data',
getUserProfile: 'fetch user data',
setUserProfile: 'modify user data',
uploadFile: 'upload file',
videoQuery: 'fetch video data',
},
hide: 'Hide',
level: {
b: 'Beginner',
Expand All @@ -15,6 +24,8 @@ export const en = {
dg: 'Recursive Chord'
},
msg: {
actionFail: 'Failed to {0}',
actionSuccess: 'Succeed to {0}',
agreeTAC: 'Please agree to Terms and Conditions!',
confirmPasswordFail: 'Passwords do not match!',
connectionFail: 'Connection Fails!',
Expand All @@ -23,15 +34,19 @@ export const en = {
emptyEmailCode: 'Please enter 6-char email code!',
emptyPassword: 'Please enter your password!',
emptyUsername: 'Please enter your username!',
fileTooLarge: 'Maximum file size is {0}',
invalidEmail: 'Invalid email!',
invalidEmailCode: 'Email code is invalid! Please re-sent your email code.',
invalidPassword: 'The length of password should be from 6 to 20!。',
invalidUsername: 'The length of username cannot exceed 20!',
logoutFail: 'Failed to log out!',
logoutSuccess: 'Log out success!',
realNameRequired: 'Real name required',
},
prop: {
action: 'Action',
designator: 'Designator',
fileName: 'File name',
is: 'Island',
level: 'Level',
op: 'Opening',
Expand All @@ -42,18 +57,29 @@ export const en = {
timems: 'Time',
upload_time: 'Upload time',
},
response: {
OK: '',
BadRequest: 'Unrecognised request',
Forbidden: 'Permission denied',
InternalServerError: 'Internal server error',
NotFound: 'Data not found',
PayloadTooLarge: 'Payload too large',
TooManyRequests: 'Too many requests',
UnsupportedMediaType: 'Unsupported file type',
},
show: 'Show',
toDo: 'TODO',
},
forgetPassword: {
title: 'Reset password',
email: 'email',
captcha: 'captcha',
getEmailCode: 'Send one-time password',
confirm: 'Reset',
confirmPassword: 'confirm password',
email: 'email',
emailCode: 'one-time password',
getEmailCode: 'Send one-time password',
password: 'new password',
confirmPassword: 'confirm password',
confirm: 'Reset'
success: 'Password reset complete!'
},
login: {
title: 'Login',
Expand Down Expand Up @@ -90,6 +116,13 @@ export const en = {
confirmChange: 'Confirm',
cancelChange: 'Cancel',
designator: 'My designators: ',
msg: {
avatarChange: 'Avatar change complete! {0} times left',
avatarFormat: 'Avatar file has to be in JPG or PNG format!',
avatarFilesize: 'Maximum file size is 50MB!',
realnameChange: 'Real name change complete! {0} times left',
signatureChange: 'Signature change complete! {0} times left',
},
records: {
title: 'Personal Records',
modeRecord: ' mode record: '
Expand All @@ -115,6 +148,19 @@ export const en = {
}
}
},
register: {
title: 'Register',
username: 'username',
email: 'email',
captcha: 'captcha',
getEmailCode: 'Send email code',
emailCode: 'email code',
password: 'password',
confirmPassword: 'confirm password',
agreeTo: 'Agree to ',
termsAndConditions: 'Terms & Conditions',
confirm: 'Register',
},
setting: {
appearance: 'Appearance',
darkMode: 'Dark Mode',
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions front_end/src/i18n/locales/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const zhCn = {
InternalServerError: '后端发生错误',
NotFound: '找不到数据',
PayloadTooLarge: '文件过大',
TooManyRequests: '请求过于频繁',
UnsupportedMediaType: '不支持的文件类型',
},
show: '显示',
Expand Down
1 change: 1 addition & 0 deletions front_end/src/utils/system/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const notificationMessage: { [code: number]: string} = {
404: 'common.response.NotFound',
413: 'common.response.PayloadTooLarge',
415: 'common.response.UnsupportedMediaType',
429: 'common.response.TooManyRequests',
500: 'common.response.InternalServerError',
};

Expand Down

0 comments on commit e2951f8

Please sign in to comment.