From 088bbac543a228319f5ee4dd1247c7b6e48eb794 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:34:13 +0100 Subject: [PATCH 1/4] fix: use dummy translations for custom field labels (#49875) (cherry picked from commit 9a989a84fb59c7c9a0da6bd4d8f567667e0fc1bc) # Conflicts: # erpnext/setup/install.py # erpnext/setup/setup_wizard/operations/install_fixtures.py --- erpnext/setup/install.py | 11 +++++++---- .../setup_wizard/operations/install_fixtures.py | 6 +++++- erpnext/setup/utils.py | 12 ++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index b826c52f20e..fb09598a450 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -4,7 +4,6 @@ import click import frappe -from frappe import _ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to from frappe.utils import cint @@ -12,6 +11,7 @@ from frappe.utils import cint import erpnext from erpnext.setup.default_energy_point_rules import get_default_energy_point_rules from erpnext.setup.doctype.incoterm.incoterm import create_incoterms +from erpnext.setup.utils import identity as _ from .default_success_action import get_default_success_action @@ -193,22 +193,25 @@ def add_company_to_session_defaults(): def add_standard_navbar_items(): navbar_settings = frappe.get_single("Navbar Settings") +<<<<<<< HEAD +======= +>>>>>>> 9a989a84fb (fix: use dummy translations for custom field labels (#49875)) erpnext_navbar_items = [ { - "item_label": "Documentation", + "item_label": _("Documentation"), "item_type": "Route", "route": "https://docs.erpnext.com/", "is_standard": 1, }, { - "item_label": "User Forum", + "item_label": _("User Forum"), "item_type": "Route", "route": "https://discuss.frappe.io", "is_standard": 1, }, { - "item_label": "Frappe School", + "item_label": _("Frappe School"), "item_type": "Route", "route": "https://frappe.io/school?utm_source=in_app", "is_standard": 1, diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 0f3356ffa50..5c5d47730eb 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -16,6 +16,10 @@ from frappe.utils import cstr, getdate from erpnext.accounts.doctype.account.account import RootNotEditable from erpnext.regional.address_template.setup import set_up_address_templates +<<<<<<< HEAD +======= +from erpnext.setup.utils import identity as _ +>>>>>>> 9a989a84fb (fix: use dummy translations for custom field labels (#49875)) def read_lines(filename: str) -> list[str]: @@ -550,7 +554,7 @@ def create_bank_account(args, demo=False): return doc except RootNotEditable: - frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account"))) + frappe.throw(frappe._("Bank account cannot be named as {0}").format(args.get("bank_account"))) except frappe.DuplicateEntryError: # bank account same as a CoA entry pass diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py index eae5c9f6c74..b7436a140f8 100644 --- a/erpnext/setup/utils.py +++ b/erpnext/setup/utils.py @@ -234,3 +234,15 @@ def welcome_email(): site_name = get_default_company() or "ERPNext" title = _("Welcome to {0}").format(site_name) return title + + +def identity(x, *args, **kwargs): + """Used for redefining the translation function to return the string as is. + + We want to create english records but still mark the strings as translatable. + E.g. when the respective DocTypes have 'Translate Link Fields' enabled or + we're creating custom fields. + + Use like this: `from erpnext.setup.utils import identity as _` + """ + return x From e29a384f902e8e5a8bc563ce1752fc3cce452d1b Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:39:40 +0100 Subject: [PATCH 2/4] chore: resolve conflicts --- erpnext/setup/install.py | 5 ----- erpnext/setup/setup_wizard/operations/install_fixtures.py | 4 ---- 2 files changed, 9 deletions(-) diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index fb09598a450..c7082122a15 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -6,7 +6,6 @@ import click import frappe from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to -from frappe.utils import cint import erpnext from erpnext.setup.default_energy_point_rules import get_default_energy_point_rules @@ -193,10 +192,6 @@ def add_company_to_session_defaults(): def add_standard_navbar_items(): navbar_settings = frappe.get_single("Navbar Settings") -<<<<<<< HEAD - -======= ->>>>>>> 9a989a84fb (fix: use dummy translations for custom field labels (#49875)) erpnext_navbar_items = [ { "item_label": _("Documentation"), diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 5c5d47730eb..758a05f0736 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -7,7 +7,6 @@ import os from pathlib import Path import frappe -from frappe import _ from frappe.desk.doctype.global_search_settings.global_search_settings import ( update_global_search_doctypes, ) @@ -16,10 +15,7 @@ from frappe.utils import cstr, getdate from erpnext.accounts.doctype.account.account import RootNotEditable from erpnext.regional.address_template.setup import set_up_address_templates -<<<<<<< HEAD -======= from erpnext.setup.utils import identity as _ ->>>>>>> 9a989a84fb (fix: use dummy translations for custom field labels (#49875)) def read_lines(filename: str) -> list[str]: From 19dc26ea16cbb963fb6353c4c16d2aebb1be26fa Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:51:05 +0100 Subject: [PATCH 3/4] revert: changes to install_fixtures I think this would be too breaking. Custom apps might expect the translated data to exist. --- erpnext/setup/setup_wizard/operations/install_fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 758a05f0736..0f3356ffa50 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -7,6 +7,7 @@ import os from pathlib import Path import frappe +from frappe import _ from frappe.desk.doctype.global_search_settings.global_search_settings import ( update_global_search_doctypes, ) @@ -15,7 +16,6 @@ from frappe.utils import cstr, getdate from erpnext.accounts.doctype.account.account import RootNotEditable from erpnext.regional.address_template.setup import set_up_address_templates -from erpnext.setup.utils import identity as _ def read_lines(filename: str) -> list[str]: @@ -550,7 +550,7 @@ def create_bank_account(args, demo=False): return doc except RootNotEditable: - frappe.throw(frappe._("Bank account cannot be named as {0}").format(args.get("bank_account"))) + frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account"))) except frappe.DuplicateEntryError: # bank account same as a CoA entry pass From ec3a226a83c3ec2245d668f5b8877596e83fa319 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:54:34 +0100 Subject: [PATCH 4/4] fix: mark navbar item as translatable --- erpnext/setup/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index c7082122a15..2dd05b1a7b8 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -212,7 +212,7 @@ def add_standard_navbar_items(): "is_standard": 1, }, { - "item_label": "Report an Issue", + "item_label": _("Report an Issue"), "item_type": "Route", "route": "https://github.com/frappe/erpnext/issues", "is_standard": 1,