mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 03:49:00 +08:00
Always build binary translations files at build time
This commit is contained in:
parent
1feadb4be7
commit
b9a915024e
29
conanfile.py
29
conanfile.py
@ -24,7 +24,8 @@ class CuraConan(ConanFile):
|
|||||||
build_policy = "missing"
|
build_policy = "missing"
|
||||||
exports = "LICENSE*", "*.jinja"
|
exports = "LICENSE*", "*.jinja"
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
generators = "VirtualPythonEnv"#, "VirtualRunEnv"
|
generators = "VirtualPythonEnv"
|
||||||
|
tool_requires = "gettext/0.21"
|
||||||
|
|
||||||
# FIXME: Remove specific branch once merged to main
|
# FIXME: Remove specific branch once merged to main
|
||||||
python_requires = "translationextractor/[>=2.2.0]@ultimaker/cura_11622"
|
python_requires = "translationextractor/[>=2.2.0]@ultimaker/cura_11622"
|
||||||
@ -36,7 +37,7 @@ class CuraConan(ConanFile):
|
|||||||
"display_name": ["ANY"], # TODO: should this be an option??
|
"display_name": ["ANY"], # TODO: should this be an option??
|
||||||
"cura_debug_mode": [True, False], # FIXME: Use profiles
|
"cura_debug_mode": [True, False], # FIXME: Use profiles
|
||||||
"internal": [True, False],
|
"internal": [True, False],
|
||||||
"enable_i18n": [True, False],
|
"i18n_extract": [True, False],
|
||||||
}
|
}
|
||||||
default_options = {
|
default_options = {
|
||||||
"enterprise": False,
|
"enterprise": False,
|
||||||
@ -45,17 +46,13 @@ class CuraConan(ConanFile):
|
|||||||
"display_name": "UltiMaker Cura",
|
"display_name": "UltiMaker Cura",
|
||||||
"cura_debug_mode": False, # Not yet implemented
|
"cura_debug_mode": False, # Not yet implemented
|
||||||
"internal": False,
|
"internal": False,
|
||||||
"enable_i18n": False,
|
"i18n_extract": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_version(self):
|
def set_version(self):
|
||||||
if not self.version:
|
if not self.version:
|
||||||
self.version = self.conan_data["version"]
|
self.version = self.conan_data["version"]
|
||||||
|
|
||||||
@property
|
|
||||||
def _i18n_options(self):
|
|
||||||
return self.conf.get("user.i18n:options", default = {"extract": True, "build": True}, check_type = dict)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _app_name(self):
|
def _app_name(self):
|
||||||
if self.options.enterprise:
|
if self.options.enterprise:
|
||||||
@ -275,15 +272,14 @@ class CuraConan(ConanFile):
|
|||||||
copy(self, "*", os.path.join(self.recipe_folder, ".run_templates"), os.path.join(self.export_sources_folder, ".run_templates"))
|
copy(self, "*", os.path.join(self.recipe_folder, ".run_templates"), os.path.join(self.export_sources_folder, ".run_templates"))
|
||||||
copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
|
copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
|
||||||
|
|
||||||
def config_options(self):
|
|
||||||
if self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
|
||||||
del self.options.enable_i18n
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
|
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
|
||||||
if version and Version(version) <= Version("4"):
|
if version and Version(version) <= Version("4"):
|
||||||
raise ConanInvalidConfiguration("Only versions 5+ are support")
|
raise ConanInvalidConfiguration("Only versions 5+ are support")
|
||||||
|
|
||||||
|
if self.options.i18n_extract and self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||||
|
raise ConanInvalidConfiguration("Unable to extract translations on Windows without Bash installed")
|
||||||
|
|
||||||
def requirements(self):
|
def requirements(self):
|
||||||
for req in self.conan_data["requirements"]:
|
for req in self.conan_data["requirements"]:
|
||||||
if self.options.internal and "fdm_materials" in req:
|
if self.options.internal and "fdm_materials" in req:
|
||||||
@ -297,10 +293,6 @@ class CuraConan(ConanFile):
|
|||||||
self.requires(req)
|
self.requires(req)
|
||||||
self.requires("cpython/3.12.2")
|
self.requires("cpython/3.12.2")
|
||||||
|
|
||||||
def build_requirements(self):
|
|
||||||
if self.options.get_safe("enable_i18n", False):
|
|
||||||
self.test_requires("gettext/0.21")
|
|
||||||
|
|
||||||
def layout(self):
|
def layout(self):
|
||||||
self.folders.source = "."
|
self.folders.source = "."
|
||||||
self.folders.build = "build"
|
self.folders.build = "build"
|
||||||
@ -352,7 +344,7 @@ class CuraConan(ConanFile):
|
|||||||
cura_private_data = self.dependencies["cura_private_data"].cpp_info
|
cura_private_data = self.dependencies["cura_private_data"].cpp_info
|
||||||
copy(self, "*", cura_private_data.resdirs[0], str(self._share_dir.joinpath("cura")))
|
copy(self, "*", cura_private_data.resdirs[0], str(self._share_dir.joinpath("cura")))
|
||||||
|
|
||||||
if self.options.get_safe("enable_i18n", False) and self._i18n_options["extract"]:
|
if self.options.i18n_extract:
|
||||||
vb = VirtualBuildEnv(self)
|
vb = VirtualBuildEnv(self)
|
||||||
vb.generate()
|
vb.generate()
|
||||||
|
|
||||||
@ -362,7 +354,10 @@ class CuraConan(ConanFile):
|
|||||||
pot.generate()
|
pot.generate()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
if self.options.get_safe("enable_i18n", False) and self._i18n_options["build"]:
|
if self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||||
|
self.output.warning("Skipping generation of binary translation files because Bash could not be found and is required")
|
||||||
|
return
|
||||||
|
|
||||||
for po_file in Path(self.source_folder, "resources", "i18n").glob("**/*.po"):
|
for po_file in Path(self.source_folder, "resources", "i18n").glob("**/*.po"):
|
||||||
mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_folder))
|
mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_folder))
|
||||||
mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)
|
mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user