Added the JavaScript text message translation.

This commit is contained in:
依瑪貓 2020-08-06 01:39:51 +08:00
parent 372e55b028
commit b45c06ac36
2 changed files with 49 additions and 30 deletions

View File

@ -0,0 +1,43 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-06 01:34+0800\n"
"PO-Revision-Date: 2020-08-06 01:38+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: accounting/static/accounting/js/transaction-form.js:369
msgid "Please fill in the date."
msgstr "請填上日期。"
#: accounting/static/accounting/js/transaction-form.js:389
msgid "Please select the account."
msgstr "請選擇會計科目。"
#: accounting/static/accounting/js/transaction-form.js:410
msgid "This summary is too long (max. 128 characters)."
msgstr "摘要太長了最長128個字。"
#: accounting/static/accounting/js/transaction-form.js:431
msgid "Please fill in the amount."
msgstr "請填上金額。"
#: accounting/static/accounting/js/transaction-form.js:463
msgid "The total amount of debit and credit records are inconsistent."
msgstr "借方和貸方合計不符。"
#: accounting/static/accounting/js/transaction-form.js:484
msgid "This note is too long (max. 128 characters)."
msgstr "註記太長了最長128個字。"

View File

@ -66,30 +66,6 @@ $(function () {
});
});
/**
* The localized messages
* @type {Array.}
* @private
*/
let l10n = null;
/**
* Returns the localization of a message.
*
* @param {string} key the message key
* @returns {string} the localized message
* @private
*/
function __(key) {
if (l10n === null) {
l10n = JSON.parse($("#l10n-messages").val());
}
if (key in l10n) {
return l10n[key];
}
return key;
}
/**
* Returns whether this is a transfer transaction.
*
@ -390,7 +366,7 @@ function validateDate() {
const errorMessage = $("#txn-date-error");
if (date.value === "") {
date.classList.add("is-invalid");
errorMessage.text(__("Please fill in the date."));
errorMessage.text(gettext("Please fill in the date."));
return false;
}
date.classList.remove("is-invalid");
@ -410,7 +386,7 @@ function validateAccount(account) {
const errorMessage = $("#" + account.id + "-error");
if (account.value === "") {
account.classList.add("is-invalid");
errorMessage.text(__("Please select the account."));
errorMessage.text(gettext("Please select the account."));
return false;
}
account.classList.remove("is-invalid");
@ -431,7 +407,7 @@ function validateSummary(summary) {
summary.value = summary.value.trim();
if (summary.value.length > 128) {
summary.classList.add("is-invalid");
errorMessage.text(__("This summary is too long (max. 128 characters)."));
errorMessage.text(gettext("This summary is too long (max. 128 characters)."));
return false;
}
summary.classList.remove("is-invalid");
@ -452,7 +428,7 @@ function validateAmount(amount) {
amount.value = amount.value.trim();
if (amount.value === "") {
amount.classList.add("is-invalid");
errorMessage.text(__("Please fill in the amount."));
errorMessage.text(gettext("Please fill in the amount."));
return false;
}
amount.classList.remove("is-invalid");
@ -484,7 +460,7 @@ function validateBalance() {
});
if (debitTotal !== creditTotal) {
balanceRows.addClass("is-invalid");
errorMessages.text(__("The sum of debit and credit are inconsistent."))
errorMessages.text(gettext("The total amount of debit and credit records are inconsistent."))
return false;
}
balanceRows.removeClass("is-invalid");
@ -505,7 +481,7 @@ function validateNote() {
note.value = note.value.trim();
if (note.value.length > 128) {
note.classList.add("is-invalid");
errorMessage.text(__("This note is too long (max. 128 characters)."));
errorMessage.text(gettext("This note is too long (max. 128 characters)."));
return false;
}
note.classList.remove("is-invalid");