Skip to content

Commit

Permalink
i18n: add Chinese and Japanese language support for message (vrcx-tea…
Browse files Browse the repository at this point in the history
  • Loading branch information
Map1en authored and Natsumi-sama committed Dec 12, 2024
1 parent 6ab68ce commit 829bf16
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 54 deletions.
102 changes: 59 additions & 43 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ speechSynthesis.getVoices();
throw err;
}
$app.$message({
message: "you're not allowed to access this instance.",
message: $t('message.instance.not_allowed'),
type: 'error'
});
throw err;
Expand Down Expand Up @@ -5423,7 +5423,7 @@ speechSynthesis.getVoices();
} catch (err) {
if (!$app.dontLogMeOut) {
$app.$message({
message: 'Failed to load friends list, logging out',
message: $t('message.friend.load_failed'),
type: 'error'
});
this.logout();
Expand Down Expand Up @@ -9474,7 +9474,7 @@ speechSynthesis.getVoices();
D.isMuteChat = true;
}
$app.$message({
message: 'User moderated',
message: $t('message.user.moderated'),
type: 'success'
});
});
Expand Down Expand Up @@ -10796,16 +10796,30 @@ speechSynthesis.getVoices();
this.setPlayerModeration(D.id, 5);
}
} else {
this.$confirm(`Continue? ${command}`, 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
performUserDialogCommand(command, D.id);
const i18nPreFix = 'dialog.user.actions.';
const formattedCommand = command.toLowerCase().replace(/ /g, '_');
const displayCommandText = $t(
`${i18nPreFix}${formattedCommand}`
).includes('i18nPreFix')
? command
: $t(`${i18nPreFix}${formattedCommand}`);

this.$confirm(
$t('confirm.message', {
command: displayCommandText
}),
$t('confirm.title'),
{
confirmButtonText: $t('confirm.confirm_button'),
cancelButtonText: $t('confirm.cancel_button'),
type: 'info',
callback: (action) => {
if (action === 'confirm') {
performUserDialogCommand(command, D.id);
}
}
}
});
);
}
};

Expand Down Expand Up @@ -13790,15 +13804,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -13809,7 +13823,7 @@ speechSynthesis.getVoices();
var base64Body = btoa(r.result);
API.uploadVRCPlusIcon(base64Body).then((args) => {
$app.$message({
message: 'Icon uploaded',
message: $t('message.icon.uploaded'),
type: 'success'
});
return args;
Expand Down Expand Up @@ -13858,15 +13872,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
this.clearInviteImageUpload();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't a png",
message: $t('message.file.not_image'),
type: 'error'
});
this.clearInviteImageUpload();
Expand Down Expand Up @@ -14948,15 +14962,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't a png",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -14981,7 +14995,7 @@ speechSynthesis.getVoices();
var fileId = $utils.extractFileId(imageUrl);
if (!fileId) {
$app.$message({
message: 'Current avatar image invalid',
message: $t('message.avatar.image_invalid'),
type: 'error'
});
clearFile();
Expand Down Expand Up @@ -15284,15 +15298,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't a png",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -15317,7 +15331,7 @@ speechSynthesis.getVoices();
var fileId = $utils.extractFileId(imageUrl);
if (!fileId) {
$app.$message({
message: 'Current world image invalid',
message: $t('message.world.image_invalid'),
type: 'error'
});
clearFile();
Expand Down Expand Up @@ -15605,7 +15619,7 @@ speechSynthesis.getVoices();
$app.changeAvatarImageDialogLoading = false;
if (args.json.imageUrl === args.params.imageUrl) {
$app.$message({
message: 'Avatar image changed',
message: $t('message.avatar.image_changed'),
type: 'success'
});
$app.displayPreviousImages('Avatar', 'Change');
Expand All @@ -15619,7 +15633,7 @@ speechSynthesis.getVoices();
$app.changeWorldImageDialogLoading = false;
if (args.json.imageUrl === args.params.imageUrl) {
$app.$message({
message: 'World image changed',
message: $t('message.world.image_changed'),
type: 'success'
});
$app.displayPreviousImages('World', 'Change');
Expand Down Expand Up @@ -16495,7 +16509,7 @@ speechSynthesis.getVoices();
var D = this.screenshotMetadataDialog;
if (D.metadata.fileSizeBytes > 10000000) {
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
return;
Expand All @@ -16506,7 +16520,7 @@ speechSynthesis.getVoices();
API.uploadGalleryImage(base64Body)
.then((args) => {
$app.$message({
message: 'Gallery image uploaded',
message: $t('message.gallery.uploaded'),
type: 'success'
});
return args;
Expand All @@ -16517,7 +16531,7 @@ speechSynthesis.getVoices();
})
.catch((err) => {
$app.$message({
message: 'Failed to upload gallery image',
message: $t('message.gallery.failed'),
type: 'error'
});
console.error(err);
Expand Down Expand Up @@ -17490,15 +17504,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -17509,7 +17523,7 @@ speechSynthesis.getVoices();
var base64Body = btoa(r.result);
API.uploadGalleryImage(base64Body).then((args) => {
$app.$message({
message: 'Gallery image uploaded',
message: $t('message.gallery.uploaded'),
type: 'success'
});
return args;
Expand Down Expand Up @@ -17601,15 +17615,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -17624,7 +17638,7 @@ speechSynthesis.getVoices();
var base64Body = btoa(r.result);
API.uploadSticker(base64Body, params).then((args) => {
$app.$message({
message: 'Sticker uploaded',
message: $t('message.sticker.uploaded'),
type: 'success'
});
return args;
Expand Down Expand Up @@ -17759,15 +17773,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -17787,7 +17801,7 @@ speechSynthesis.getVoices();
var base64Body = btoa(r.result);
API.uploadPrint(base64Body, params).then((args) => {
$app.$message({
message: 'Print uploaded',
message: $t('message.print.uploaded'),
type: 'success'
});
return args;
Expand Down Expand Up @@ -17971,15 +17985,15 @@ speechSynthesis.getVoices();
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
message: $t('message.file.too_large'),
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
message: $t('message.file.not_image'),
type: 'error'
});
clearFile();
Expand All @@ -18004,7 +18018,7 @@ speechSynthesis.getVoices();
var base64Body = btoa(r.result);
API.uploadEmoji(base64Body, params).then((args) => {
$app.$message({
message: 'Emoji uploaded',
message: $t('message.emoji.uploaded'),
type: 'success'
});
return args;
Expand Down Expand Up @@ -21420,7 +21434,9 @@ speechSynthesis.getVoices();
API.queuedInstances.forEach((ref) => {
if (ref.location !== instanceId) {
$app.$message({
message: `Removed instance ${ref.$worldName} from queue`,
message: $t('message.instance.removed_form_queue', {
worldName: ref.$worldName
}),
type: 'info'
});
ref.$msgBox?.close();
Expand Down Expand Up @@ -21707,7 +21723,7 @@ speechSynthesis.getVoices();
}
} else {
$app.$message({
message: 'Failed to change avatar moderation',
message: $t('message.avatar.change_moderation_failed'),
type: 'error'
});
}
Expand Down Expand Up @@ -22197,7 +22213,7 @@ speechSynthesis.getVoices();
API.$on('INSTANCE:CLOSE', function (args) {
if (args.json) {
$app.$message({
message: 'Instance closed',
message: $t('message.instance.closed'),
type: 'success'
});

Expand Down Expand Up @@ -22376,7 +22392,7 @@ speechSynthesis.getVoices();
API.$on('BADGE:UPDATE', function (args) {
if (args.json) {
$app.$message({
message: 'Badge updated',
message: $t('message.badge.updated'),
type: 'success'
});
}
Expand Down
4 changes: 3 additions & 1 deletion html/src/classes/apiRequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ export default class extends baseClass {
endpoint.startsWith('avatars/')
) {
$app.$message({
message: 'Avatar private or deleted',
message: $t(
'message.api_headler.avatar_private_or_deleted'
),
type: 'error'
});
$app.avatarDialog.visible = false;
Expand Down
4 changes: 3 additions & 1 deletion html/src/classes/vrcxUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export default class extends baseClass {
var releases = [];
if (typeof json !== 'object' || json.message) {
$app.$message({
message: `Failed to check for update, "${json.message}"`,
message: $t('message.vrcx_updater.failed', {
message: json.message
}),
type: 'error'
});
return;
Expand Down
Loading

0 comments on commit 829bf16

Please sign in to comment.