Skip to content

Commit 41bb2a3

Browse files
committed
Fix issues with translations.
1 parent 0d6a130 commit 41bb2a3

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

icons/translations.png

7.54 KB
Loading

mob.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ python = release
143143
third_party =
144144
prefix =
145145
cache =
146+
icons =
146147
patches =
147148
licenses =
148149
build =

src/core/conf.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ namespace mob {
518518
set_path_if_empty("vcpkg", find_vcpkg); // set after vs as it will use the VS
519519
set_path_if_empty("qt_install", find_qt);
520520
set_path_if_empty("temp_dir", find_temp_dir);
521+
set_path_if_empty("icons", find_in_root("icons"));
521522
set_path_if_empty("patches", find_in_root("patches"));
522523
set_path_if_empty("licenses", find_in_root("licenses"));
523524
set_path_if_empty("qt_bin", qt::installation_path() / "bin");

src/core/conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ namespace mob {
263263
VALUE(third_party);
264264
VALUE(prefix);
265265
VALUE(cache);
266+
VALUE(icons);
266267
VALUE(patches);
267268
VALUE(licenses);
268269
VALUE(build);

src/tasks/translations.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,23 @@ namespace mob::tasks {
259259
{
260260
using json = nlohmann::ordered_json;
261261

262-
json metadata;
263-
{
264-
std::ifstream ifs(path);
265-
metadata = json::parse(ifs);
266-
}
262+
json metadata = json::parse(R"(
263+
{
264+
"id": "mo2-translations",
265+
"name": "Translations for ModOrganizer2",
266+
"version": "1.0.0",
267+
"description": "Multi-language translations for ModOrganizer2 itself.",
268+
"author": {
269+
"name": "Mod Organizer 2",
270+
"homepage": "https://www.modorganizer.org/"
271+
},
272+
"icon": "translations.png",
273+
"type": "translation",
274+
"content": {
275+
"translations": {}
276+
}
277+
}
278+
)");
267279

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

336348
if (!fs::exists(base)) {
337-
cx().warning(context::generic,
338-
"found project {} for extension {} extension is not built",
339-
p.name, project_to_extension[p.name]);
349+
cx().warning(
350+
context::generic,
351+
"found project {} for extension {} but extension is not built",
352+
p.name, project_to_extension[p.name]);
340353
continue;
341354
}
342355

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

364377
if (auto p = ps.find("organizer")) {
365-
// the empty metadata for mo2-translations is copied from modorganizer and
366-
// then filled here
367-
generate_translations_metadata(
368-
extensions / "mo2-translations" / "metadata.json", p->langs);
378+
// copy Qt builting translation, icon and generate metadata
369379
copy_builtin_qt_translations(*p, extensions / "mo2-translations" /
370380
"translations");
381+
op::copy_file_to_file_if_better(
382+
cx(), conf().path().icons() / "translations.png",
383+
extensions / "mo2-translations" / "translations.png", op::unsafe);
384+
generate_translations_metadata(
385+
extensions / "mo2-translations" / "metadata.json", p->langs);
371386
}
372387
else
373-
cx().bail_out(context::generic, "organizer project not found");
388+
cx().warning(context::generic, "organizer project not found");
374389
}
375390

376391
void translations::copy_builtin_qt_translations(const projects::project& p,

0 commit comments

Comments
 (0)