Skip to content

Commit

Permalink
Fix issues with translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 9, 2024
1 parent 0d6a130 commit 41bb2a3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Binary file added icons/translations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mob.ini
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ python = release
third_party =
prefix =
cache =
icons =
patches =
licenses =
build =
Expand Down
1 change: 1 addition & 0 deletions src/core/conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ namespace mob {
set_path_if_empty("vcpkg", find_vcpkg); // set after vs as it will use the VS
set_path_if_empty("qt_install", find_qt);
set_path_if_empty("temp_dir", find_temp_dir);
set_path_if_empty("icons", find_in_root("icons"));
set_path_if_empty("patches", find_in_root("patches"));
set_path_if_empty("licenses", find_in_root("licenses"));
set_path_if_empty("qt_bin", qt::installation_path() / "bin");
Expand Down
1 change: 1 addition & 0 deletions src/core/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ namespace mob {
VALUE(third_party);
VALUE(prefix);
VALUE(cache);
VALUE(icons);
VALUE(patches);
VALUE(licenses);
VALUE(build);
Expand Down
41 changes: 28 additions & 13 deletions src/tasks/translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,23 @@ namespace mob::tasks {
{
using json = nlohmann::ordered_json;

json metadata;
{
std::ifstream ifs(path);
metadata = json::parse(ifs);
}
json metadata = json::parse(R"(
{
"id": "mo2-translations",
"name": "Translations for ModOrganizer2",
"version": "1.0.0",
"description": "Multi-language translations for ModOrganizer2 itself.",
"author": {
"name": "Mod Organizer 2",
"homepage": "https://www.modorganizer.org/"
},
"icon": "translations.png",
"type": "translation",
"content": {
"translations": {}
}
}
)");

// fix version
json translations;
Expand Down Expand Up @@ -334,9 +346,10 @@ namespace mob::tasks {
const auto base = extensions / project_to_extension[p.name];

if (!fs::exists(base)) {
cx().warning(context::generic,
"found project {} for extension {} extension is not built",
p.name, project_to_extension[p.name]);
cx().warning(
context::generic,
"found project {} for extension {} but extension is not built",
p.name, project_to_extension[p.name]);
continue;
}

Expand All @@ -362,15 +375,17 @@ namespace mob::tasks {
parallel(v);

if (auto p = ps.find("organizer")) {
// the empty metadata for mo2-translations is copied from modorganizer and
// then filled here
generate_translations_metadata(
extensions / "mo2-translations" / "metadata.json", p->langs);
// copy Qt builting translation, icon and generate metadata
copy_builtin_qt_translations(*p, extensions / "mo2-translations" /
"translations");
op::copy_file_to_file_if_better(
cx(), conf().path().icons() / "translations.png",
extensions / "mo2-translations" / "translations.png", op::unsafe);
generate_translations_metadata(
extensions / "mo2-translations" / "metadata.json", p->langs);
}
else
cx().bail_out(context::generic, "organizer project not found");
cx().warning(context::generic, "organizer project not found");
}

void translations::copy_builtin_qt_translations(const projects::project& p,
Expand Down

0 comments on commit 41bb2a3

Please sign in to comment.