2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

fix: preserve spaces in translation

This commit is contained in:
18alantom 2022-02-07 14:11:10 +05:30
parent 9b30142cf0
commit 8ba9f7f510
3 changed files with 10 additions and 20 deletions

View File

@ -409,16 +409,13 @@ module.exports = class BaseDocument extends Observable {
// check for conflict
if (currentDoc && this.modified != currentDoc.modified) {
throw new frappe.errors.Conflict(
frappe.t('Document {0} {1} has been modified after loading', [
this.doctype,
this.name,
])
frappe.t`Document ${this.doctype} ${this.name} has been modified after loading`
);
}
if (this.submitted && !this.meta.isSubmittable) {
throw new frappe.errors.ValidationError(
frappe.t('Document type {1} is not submittable', [this.doctype])
frappe.t`Document type ${this.doctype} is not submittable`
);
}

View File

@ -34,17 +34,16 @@ class TranslationString {
}
#translate(segment) {
const startSpace = segment.match(/^\s+/)?.[0] ?? '';
const endSpace = segment.match(/\s+$/)?.[0] ?? '';
segment = segment.replace(/\s+/g, ' ').trim();
// TODO: implement translation backend
return segment;
// segment = translate(segment)
return startSpace + segment + endSpace;
}
#formatArg(arg) {
if (typeof arg === 'undefined') {
return ' ';
}
return ` ${arg} `;
return arg ?? '';
}
#stitch() {

View File

@ -34,10 +34,7 @@ export async function showMessageDialog({
export function deleteDocWithPrompt(doc) {
return new Promise((resolve) => {
showMessageDialog({
message: t('Are you sure you want to delete {0} "{1}"?', [
doc.doctype,
doc.name,
]),
message: t`Are you sure you want to delete ${doc.doctype} "${doc.name}"?`,
description: t('This action is permanent'),
buttons: [
{
@ -65,11 +62,8 @@ export function deleteDocWithPrompt(doc) {
export function cancelDocWithPrompt(doc) {
return new Promise((resolve) => {
showMessageDialog({
message: t('Are you sure you want to cancel {0} "{1}"?', [
doc.doctype,
doc.name,
]),
description: t('This action is permanent'),
message: t`Are you sure you want to cancel ${doc.doctype} ${doc.name}?`,
description: t`This action is permanent`,
buttons: [
{
label: t('Yes'),