Skip to content

Commit 3ace99e

Browse files
committed
Add API response translations for various entities and actions
- Introduced new translation keys in English and Portuguese for API responses related to entities such as users, products, invoices, and taxes. - Updated controller responses to utilize the new translation keys for consistency and localization. - Ensured that messages for actions like creation, deletion, updates, and errors are now translatable. - Refactored existing messages in controllers to use the translation function for better internationalization support.
1 parent 51b98f1 commit 3ace99e

File tree

45 files changed

+245
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+245
-84
lines changed

backend/public/translations/en/common.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,66 @@
88
"some_error_occurred": "Some error occurred"
99
}
1010
},
11+
"api": {
12+
"entity_created": "{{entity}} created",
13+
"entity_deleted": "{{entity}} deleted",
14+
"entity_linked": "{{entity}} is linked",
15+
"select_at_least_one_recipient": "Select at least one recipient",
16+
"attachment_sent": "Attachment sent",
17+
"user_logged_out": "User logged out",
18+
"user_details_updated": "User details updated",
19+
"user_activated": "User activated",
20+
"user_deactivated": "User deactivated",
21+
"avatar_removed": "Avatar removed",
22+
"password_reset_done": "Password reset completed",
23+
"password_reset_successful": "Password reset successful",
24+
"email_already_verified": "Email already verified",
25+
"organization_registered": "Organization registered",
26+
"organization_details_updated": "Organization details updated",
27+
"logo_removed": "Logo removed",
28+
"user_updated": "User updated",
29+
"financial_year_updated": "Financial year updated",
30+
"product_created": "New product created",
31+
"product_updated": "Product updated successfully",
32+
"product_retrieved": "Product retrieved successfully",
33+
"product_deleted": "Product deleted successfully",
34+
"products_created": "Products created",
35+
"products_retrieved": "Products retrieved successfully",
36+
"contact_updated": "Contact updated",
37+
"payment_added": "Payment added",
38+
"invoice_created_with_number": "Invoice {{num}} created",
39+
"transactions_retrieved": "Transactions retrieved successfully",
40+
"party_updated": "Party updated",
41+
"party_deleted": "Party deleted",
42+
"no_file_uploaded": "No file uploaded",
43+
"import_job_created": "Import job created",
44+
"tax_created": "Tax created",
45+
"tax_enabled": "Enabled tax",
46+
"tax_disabled": "Disabled tax",
47+
"cannot_remove_default_tax": "Cannot remove default tax",
48+
"tax_linked_to_grouped_tax": "Tax linked to grouped tax",
49+
"tax_linked_to_invoice": "Tax linked to invoice",
50+
"tax_linked_to_purchase": "Tax linked to purchase",
51+
"tax_linked_to_purchase_order": "Tax linked to purchase order",
52+
"tax_linked_to_proforma_invoice": "Tax linked to proforma invoice",
53+
"tax_deleted": "Tax deleted",
54+
"um_created": "UM created",
55+
"um_updated": "UM updated",
56+
"um_not_found": "UM not found",
57+
"cannot_remove_default_unit": "Cannot remove default unit",
58+
"unit_linked_to_product": "Unit linked to product",
59+
"unit_linked_to_invoice": "Unit linked to invoice",
60+
"unit_linked_to_purchase": "Unit linked to purchase",
61+
"unit_linked_to_purchase_order": "Unit linked to purchase order",
62+
"unit_linked_to_proforma_invoice": "Unit linked to proforma invoice",
63+
"unit_not_found": "Unit not found",
64+
"unit_deleted": "Unit deleted",
65+
"expense_deleted": "Expense deleted successfully",
66+
"setting_not_found": "Setting not found",
67+
"product_category_not_found": "Product category not found",
68+
"product_category_used_by_product": "Product category used by product",
69+
"product_category_deleted": "Product category deleted successfully"
70+
},
1171
"about": {
1272
"heading": "Unlock the Power of Seamless Business Operations",
1373
"distributed_by": "Distributed by",

backend/public/translations/pt/common.json

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,66 @@
88
"some_error_occurred": "Ocorreu algum erro"
99
}
1010
},
11+
"api": {
12+
"entity_created": "{{entity}} criado",
13+
"entity_deleted": "{{entity}} excluído",
14+
"entity_linked": "{{entity}} está vinculado",
15+
"select_at_least_one_recipient": "Selecione pelo menos um destinatário",
16+
"attachment_sent": "Anexo enviado",
17+
"user_logged_out": "Usuário desconectado",
18+
"user_details_updated": "Detalhes do usuário atualizados",
19+
"user_activated": "Usuário ativado",
20+
"user_deactivated": "Usuário desativado",
21+
"avatar_removed": "Avatar removido",
22+
"password_reset_done": "Redefinição de senha concluída",
23+
"password_reset_successful": "Senha redefinida com sucesso",
24+
"email_already_verified": "E-mail já verificado",
25+
"organization_registered": "Organização registrada",
26+
"organization_details_updated": "Detalhes da organização atualizados",
27+
"logo_removed": "Logo removido",
28+
"user_updated": "Usuário atualizado",
29+
"financial_year_updated": "Ano fiscal atualizado",
30+
"product_created": "Novo produto criado",
31+
"product_updated": "Produto atualizado com sucesso",
32+
"product_retrieved": "Produto recuperado com sucesso",
33+
"product_deleted": "Produto excluído com sucesso",
34+
"products_created": "Produtos criados",
35+
"products_retrieved": "Produtos recuperados com sucesso",
36+
"contact_updated": "Contato atualizado",
37+
"payment_added": "Pagamento adicionado",
38+
"invoice_created_with_number": "Fatura {{num}} criada",
39+
"transactions_retrieved": "Transações recuperadas com sucesso",
40+
"party_updated": "Contato atualizado",
41+
"party_deleted": "Contato excluído",
42+
"no_file_uploaded": "Nenhum arquivo enviado",
43+
"import_job_created": "Tarefa de importação criada",
44+
"tax_created": "Imposto criado",
45+
"tax_enabled": "Imposto ativado",
46+
"tax_disabled": "Imposto desativado",
47+
"cannot_remove_default_tax": "Não é possível remover o imposto padrão",
48+
"tax_linked_to_grouped_tax": "Imposto vinculado a imposto agrupado",
49+
"tax_linked_to_invoice": "Imposto vinculado à fatura",
50+
"tax_linked_to_purchase": "Imposto vinculado à compra",
51+
"tax_linked_to_purchase_order": "Imposto vinculado ao pedido de compra",
52+
"tax_linked_to_proforma_invoice": "Imposto vinculado à fatura proforma",
53+
"tax_deleted": "Imposto excluído",
54+
"um_created": "Unidade de medida criada",
55+
"um_updated": "Unidade de medida atualizada",
56+
"um_not_found": "Unidade de medida não encontrada",
57+
"cannot_remove_default_unit": "Não é possível remover a unidade padrão",
58+
"unit_linked_to_product": "Unidade vinculada ao produto",
59+
"unit_linked_to_invoice": "Unidade vinculada à fatura",
60+
"unit_linked_to_purchase": "Unidade vinculada à compra",
61+
"unit_linked_to_purchase_order": "Unidade vinculada ao pedido de compra",
62+
"unit_linked_to_proforma_invoice": "Unidade vinculada à fatura proforma",
63+
"unit_not_found": "Unidade não encontrada",
64+
"unit_deleted": "Unidade excluída",
65+
"expense_deleted": "Despesa excluída com sucesso",
66+
"setting_not_found": "Configuração não encontrada",
67+
"product_category_not_found": "Categoria de produto não encontrada",
68+
"product_category_used_by_product": "Categoria de produto usada por produto",
69+
"product_category_deleted": "Categoria de produto excluída com sucesso"
70+
},
1171
"about": {
1272
"heading": "Desbloqueie o poder de operações de negócios integradas",
1373
"distributed_by": "Distribuído por",
@@ -79,7 +139,7 @@
79139
"links": {
80140
"dashboard": "Painel",
81141
"stats": "Estatísticas",
82-
"parties": "Contatos",
142+
"parties": "Partes",
83143
"contacts": "Contatos",
84144
"invoices": "Faturas",
85145
"proforma_invoices": "Faturas Proforma",

backend/src/controllers/bill.controller/create.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const create = async (options = {}, req, res) => {
3030
logger.info(`${billLabel} created successfully`);
3131
return res
3232
.status(201)
33-
.json({ message: `${billLabel} created !` });
33+
.json({
34+
message: req.t("common:api.entity_created", { entity: billLabel }),
35+
});
3436
};
3537

3638
module.exports = create;

backend/src/controllers/bill.controller/remove.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Quotes = require("../../models/quotes.model");
44
const logger = require("../../logger");
55
const OrgModel = require("../../models/org.model");
66
const { deleteBill } = require("../../services/bill.service");
7+
const billTypes = require("../../constants/billTypes");
78

89
const remove = async (options = {}, req, res) => {
910
const { NotFound, Bill, relatedDocType } = options;
@@ -30,7 +31,10 @@ const remove = async (options = {}, req, res) => {
3031
{ _id: req.params.orgId },
3132
{ $inc: { [relatedDocTypeKey]: -1 } }
3233
);
33-
return res.status(200).json({ message: `${Bill.modelName} deleted !` });
34+
const billLabel = billTypes[Bill.modelName] || Bill.modelName;
35+
return res.status(200).json({
36+
message: req.t("common:api.entity_deleted", { entity: billLabel }),
37+
});
3438
};
3539

3640
module.exports = remove;

backend/src/controllers/bill.controller/send.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const send = async (options = {}, req, res) => {
2323
const purchasedBy = req.session?.user?.currentPlan?.purchasedBy;
2424
const oAuth2Client = await setupAuth2ClientByOrgOwnedBy(purchasedBy);
2525
if (!body.to.length)
26-
return res.status(200).json({ message: "Select atleast one recipent" });
26+
return res
27+
.status(200)
28+
.json({ message: req.t("common:api.select_at_least_one_recipient") });
2729
const filter = {
2830
_id: id,
2931
org: req.params.orgId,
@@ -52,7 +54,7 @@ const send = async (options = {}, req, res) => {
5254
cc: ccEmails.join(","),
5355
attachmentBuffer: pdfBuffer,
5456
});
55-
return res.status(201).json({ message: "Sent attachment" });
57+
return res.status(201).json({ message: req.t("common:api.attachment_sent") });
5658
};
5759

5860
module.exports = send;

backend/src/controllers/contact.controller/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const update = async (req, res) => {
1616
logger.log("info", `Contact updated with id ${updatedContact.id}`);
1717
return res
1818
.status(200)
19-
.json({ data: updatedContact, message: "Contact updated" });
19+
.json({ data: updatedContact, message: req.t("common:api.contact_updated") });
2020
};
2121

2222
module.exports = update;

backend/src/controllers/expenses.controller/remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const remove = async (req, res) => {
2424
{ _id: req.params.orgId },
2525
{ $inc: { "relatedDocsCount.expenses": -1 } }
2626
);
27-
return res.status(200).json({ message: "Expense deleted successfully" });
27+
return res.status(200).json({ message: req.t("common:api.expense_deleted") });
2828
};
2929

3030
module.exports = remove;

backend/src/controllers/org.controller/closeFinancialYear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const closeFinancialYear = async (req, res) => {
3434
);
3535
return res
3636
.status(200)
37-
.json({ message: "Financial year updated", data: setting });
37+
.json({ message: req.t("common:api.financial_year_updated"), data: setting });
3838
};
3939

4040
module.exports = closeFinancialYear;

backend/src/controllers/org.controller/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const create = async (req, res) => {
4444
})
4545
return res
4646
.status(201)
47-
.json({ message: "Organization registered", data: org });
47+
.json({ message: req.t("common:api.organization_registered"), data: org });
4848
};
4949

5050
module.exports = create;

backend/src/controllers/org.controller/removeLogo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const removeLogo = async (req, res) => {
77
);
88
return res
99
.status(200)
10-
.json({ status: true, message: "Logo removed" });
10+
.json({ status: true, message: req.t("common:api.logo_removed") });
1111
};
1212

1313
module.exports = removeLogo;

0 commit comments

Comments
 (0)