mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
gate qt template inclusion on extra_ftl_root name
Bazel was not noticing that the build script needs to be recompiled when the qt templates flag was changed.
This commit is contained in:
parent
0d49b3eabb
commit
6ca690a14c
1 changed files with 15 additions and 15 deletions
|
@ -6,10 +6,9 @@
|
||||||
//! in the source tree can be found. If not set (when building from cargo), the script
|
//! in the source tree can be found. If not set (when building from cargo), the script
|
||||||
//! will look in the parent folders instead.
|
//! will look in the parent folders instead.
|
||||||
//! - RSLIB_FTL_ROOT should be set to the l10n.toml file inside the core translation repo.
|
//! - RSLIB_FTL_ROOT should be set to the l10n.toml file inside the core translation repo.
|
||||||
//! - EXTRA_FTL_ROOT should be set to the l10n.toml file inside the qt translation repo.
|
//! - EXTRA_FTL_ROOT should normally be set to the l10n.toml file inside the qt translation
|
||||||
//! - If NO_QT_TEMPLATES is set, EXTRA_FTL_ROOT can be pointed at a l10n.toml file in a separate
|
//! repo. If it is pointed at a different location, the Qt translations will be excluded
|
||||||
//! location, to include files from there. In this case, the standard Qt templates will not
|
//! and the provided translations embedded instead.
|
||||||
//! be included from the source tree.
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{collections::HashMap, env};
|
use std::{collections::HashMap, env};
|
||||||
|
@ -21,14 +20,10 @@ pub type TranslationsByLang = HashMap<String, TranslationsByFile>;
|
||||||
/// Read the contents of the FTL files into a TranslationMap structure.
|
/// Read the contents of the FTL files into a TranslationMap structure.
|
||||||
pub fn get_ftl_data() -> TranslationsByLang {
|
pub fn get_ftl_data() -> TranslationsByLang {
|
||||||
let mut map = TranslationsByLang::default();
|
let mut map = TranslationsByLang::default();
|
||||||
let include_qt = include_local_qt_templates();
|
|
||||||
|
|
||||||
// English templates first
|
// English templates first
|
||||||
let ftl_base = source_tree_root();
|
let ftl_base = source_tree_root();
|
||||||
add_folder(&mut map, &ftl_base.join("core"), "templates");
|
add_folder(&mut map, &ftl_base.join("core"), "templates");
|
||||||
if include_qt {
|
|
||||||
add_folder(&mut map, &ftl_base.join("qt"), "templates");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Core translations provided?
|
// Core translations provided?
|
||||||
if let Some(path) = core_ftl_root() {
|
if let Some(path) = core_ftl_root() {
|
||||||
|
@ -37,7 +32,11 @@ pub fn get_ftl_data() -> TranslationsByLang {
|
||||||
|
|
||||||
// Extra templates/translations provided?
|
// Extra templates/translations provided?
|
||||||
if let Some(path) = extra_ftl_root() {
|
if let Some(path) = extra_ftl_root() {
|
||||||
add_translation_root(&mut map, &path, include_qt);
|
let add_qt_templates = extra_ftl_is_desktop(&path);
|
||||||
|
if add_qt_templates {
|
||||||
|
add_folder(&mut map, &ftl_base.join("qt"), "templates");
|
||||||
|
}
|
||||||
|
add_translation_root(&mut map, &path, add_qt_templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
map
|
map
|
||||||
|
@ -77,12 +76,13 @@ fn add_translation_root(map: &mut TranslationsByLang, root: &Path, ignore_templa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// In a standard build, the ftl/qt folder is used as the source
|
/// True if @extra_ftl points to the standard Qt translations,
|
||||||
/// of truth for @extra_ftl, making it easier to add new strings.
|
/// which have a desktop/ folder.
|
||||||
/// If the Qt templates are not desired, the NO_QT_TEMPLATES env
|
fn extra_ftl_is_desktop(extra_ftl_root: &Path) -> bool {
|
||||||
/// var can be set to skip them.
|
extra_ftl_root
|
||||||
fn include_local_qt_templates() -> bool {
|
.file_name()
|
||||||
env::var("NO_QT_TEMPLATES").is_err()
|
.map(|fname| fname == "desktop")
|
||||||
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source_tree_root() -> PathBuf {
|
fn source_tree_root() -> PathBuf {
|
||||||
|
|
Loading…
Reference in a new issue