diff options
| author | fiaxh <git@lightrise.org> | 2025-04-09 19:20:20 +0200 |
|---|---|---|
| committer | fiaxh <git@lightrise.org> | 2025-04-09 19:21:19 +0200 |
| commit | 50351d63c677bc9fbb5829955677fa8ff88588ca (patch) | |
| tree | 07ec0df1ffe749a3b712986498c37e47bac096e2 /libdino/src/util | |
| parent | 5024f7c815599d3a79ff1b4582e680283a15bc77 (diff) | |
Fix locale search path finding on meson builds
Diffstat (limited to 'libdino/src/util')
| -rw-r--r-- | libdino/src/util/util.vala | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libdino/src/util/util.vala b/libdino/src/util/util.vala index 31f4c105..90670377 100644 --- a/libdino/src/util/util.vala +++ b/libdino/src/util/util.vala @@ -16,12 +16,29 @@ public class SearchPathGenerator { public string get_locale_path(string gettext_package, string locale_install_dir) { string? locale_dir = null; - if (Path.get_dirname(exec_path).contains("dino") || Path.get_dirname(exec_path) == "." || Path.get_dirname(exec_path).contains("build")) { - string exec_locale = Path.build_filename(Path.get_dirname(exec_path), "locale"); + string dirname = Path.get_dirname(exec_path); + // Does our environment look like a CMake build dir? + if (dirname.contains("dino") || dirname == "." || dirname.contains("build")) { + string exec_locale = Path.build_filename(dirname, "locale"); if (FileUtils.test(Path.build_filename(exec_locale, "en", "LC_MESSAGES", gettext_package + ".mo"), FileTest.IS_REGULAR)) { locale_dir = exec_locale; } } + // Does our environment look like a meson build dir? + if (dirname == "." || Path.get_basename(dirname) == "main") { + if (gettext_package == "dino") { + string exec_locale = Path.build_filename(dirname, "po"); + if (FileUtils.test(Path.build_filename(exec_locale, "en", "LC_MESSAGES", gettext_package + ".mo"), FileTest.IS_REGULAR)) { + locale_dir = exec_locale; + } + } else if (gettext_package.has_prefix("dino-")) { + // This is a plugin, so fetch from plugin subdir + string exec_locale = Path.build_filename(dirname, "..", "plugins", gettext_package.substring(5), "po"); + if (FileUtils.test(Path.build_filename(exec_locale, "en", "LC_MESSAGES", gettext_package + ".mo"), FileTest.IS_REGULAR)) { + locale_dir = exec_locale; + } + } + } return locale_dir ?? locale_install_dir; } |
