Skip to content

Commit

Permalink
added translation for tours
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism committed Feb 18, 2025
1 parent f3d36dd commit 7ac704f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
46 changes: 43 additions & 3 deletions src/appshell/resources/tours.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,49 @@
"steps" : [
{
"control_uri": "control://NoteInputSection/NoteInputBar/note-input-by-duration",
"title": "Note input modes",
"description": "Discover different ways to input notes in MuseScore Studio.",
"video_explanation_url": "https://www.youtube.com/watch?v=OUXf7Y2CPQE&t"
"video_explanation_url": "https://www.youtube.com/watch?v=OUXf7Y2CPQE&t",
"locale": {
"en": {
"title": "Note input modes",
"description": "Discover different ways to input notes in MuseScore Studio."
},
"es": {
"title": "Modos de introducción de notas",
"description": "Descubre diferentes formas de introducir notas en MuseScore Studio."
},
"zh": {
"title": "音符输入模式",
"description": "探索在 MuseScore Studio 中输入音符的不同方式。"
},
"pt": {
"title": "Modos de entrada de notas",
"description": "Descubra diferentes maneiras de inserir notas no MuseScore Studio."
},
"ru": {
"title": "Режимы ввода нот",
"description": "Откройте для себя различные способы ввода нот в MuseScore Studio."
},
"ja": {
"title": "音符入力モード",
"description": "MuseScore Studio で音符を入力するさまざまな方法を発見しましょう。"
},
"de": {
"title": "Noteneingabemodi",
"description": "Entdecken Sie verschiedene Möglichkeiten zur Eingabe von Noten in MuseScore Studio."
},
"ko": {
"title": "음표 입력 모드",
"description": "MuseScore Studio에서 음표를 입력하는 다양한 방법을 알아보세요."
},
"it": {
"title": "Modalità di inserimento delle note",
"description": "Scopri diversi modi per inserire le note in MuseScore Studio."
},
"fr": {
"title": "Modes de saisie des notes",
"description": "Découvrez différentes façons de saisir des notes dans MuseScore Studio."
}
}
}
]
}
Expand Down
22 changes: 20 additions & 2 deletions src/framework/tours/internal/toursservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void ToursService::initTours()
return;
}

QString languageCode = languagesConfiguration()->currentLanguageCode().val;
std::string locale = QLocale(languageCode).bcp47Name().toStdString();

for (const std::string& eventCode : obj.keys()) {
Tour tour;

Expand All @@ -88,11 +91,26 @@ void ToursService::initTours()
}

TourStep step;
step.title = itemObj.value("title").toString();
step.description = itemObj.value("description").toString();
step.videoExplanationUrl = itemObj.value("video_explanation_url").toString();
step.controlUri = Uri(itemObj.value("control_uri").toString());

JsonObject itemLocaleObj = itemObj.value("locale").toObject();

if (!itemLocaleObj.contains(locale)) {
static const std::string DEFAULT_LOCALE = "en";
locale = DEFAULT_LOCALE;

if (!itemLocaleObj.contains(locale)) {
LOGE() << "failed parse, no tour content";
return;
}
}

JsonObject itemCurrentLocaleObj = itemLocaleObj.value(locale).toObject();

step.title = itemCurrentLocaleObj.value("title").toString();
step.description = itemCurrentLocaleObj.value("description").toString();

tour.steps.emplace_back(step);
}

Expand Down
2 changes: 2 additions & 0 deletions src/framework/tours/internal/toursservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "modularity/ioc.h"
#include "iinteractive.h"
#include "languages/ilanguagesconfiguration.h"
#include "itoursprovider.h"
#include "itoursconfiguration.h"

Expand All @@ -37,6 +38,7 @@ class ToursService : public IToursService, public Injectable, public async::Asyn
Inject<IInteractive> interactive = { this };
Inject<IToursProvider> toursProvider = { this };
Inject<IToursConfiguration> toursConfiguration = { this };
Inject<languages::ILanguagesConfiguration> languagesConfiguration = { this };

public:
ToursService(const muse::modularity::ContextPtr& ctx)
Expand Down

0 comments on commit 7ac704f

Please sign in to comment.