Use conf to get i18n options

This will give us more finegrained control
if we want the pot files extracted
or build the mo files

Contributes to CURA-11300
This commit is contained in:
Jelle Spijker 2023-11-24 10:18:11 +01:00
parent 670f86d218
commit 1d8918f30d
No known key found for this signature in database
GPG key ID: 034D1C0527888B65

View file

@ -52,6 +52,10 @@ class CuraConan(ConanFile):
if not self.version: if not self.version:
self.version = "5.6.0-beta.2" self.version = "5.6.0-beta.2"
@property
def _i18n_options(self):
return self.conf.get("user.i18n:options", default = {"extract": True, "build": True}, check_type = dict)
@property @property
def _pycharm_targets(self): def _pycharm_targets(self):
return self.conan_data["pycharm_targets"] return self.conan_data["pycharm_targets"]
@ -407,7 +411,7 @@ class CuraConan(ConanFile):
entitlements_file=entitlements_file if self.settings.os == "Macos" else "None" entitlements_file=entitlements_file if self.settings.os == "Macos" else "None"
) )
if self.options.get_safe("enable_i18n", False): if self.options.get_safe("enable_i18n", False) and self._i18n_options["extract"]:
# Update the po and pot files # Update the po and pot files
vb = VirtualBuildEnv(self) vb = VirtualBuildEnv(self)
vb.generate() vb.generate()
@ -418,7 +422,7 @@ class CuraConan(ConanFile):
pot.generate() pot.generate()
def build(self): def build(self):
if self.options.get_safe("enable_i18n", False): if self.options.get_safe("enable_i18n", False) and self._i18n_options["build"]:
for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"): for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_path)) mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_path))
mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name) mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)