Skip to content

Commit

Permalink
More specific loading of the localized tutorial (#285)
Browse files Browse the repository at this point in the history
* More specific loading of the localized tutorial

First try and load the file ending with the five-letter canonical form of the current locale name, e.g. `tutorial-pt_BR.cts`.
Failing that, try and load the file ending with the two-letter canonical form of the current locale name, e.g. `tutorial-pt.cts`.
Failing that, just load `tutorial.cts`, and be done with it.

* Make `LoadTut()` work when `lang` is empty
  • Loading branch information
georgeraraujo authored Nov 11, 2022
1 parent f6beea1 commit d0e582a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,17 @@ struct System {

void LoadTut() {
auto lang = frame->app->locale.GetCanonicalName();

if (lang.Len() == 5 && !LoadDB(frame->GetDocPath(L"examples/tutorial-" + lang + ".cts"))[0]) {
return;
}

lang.Truncate(2);
if (LoadDB(frame->GetDocPath(L"examples/tutorial-" + lang + ".cts"))[0]) {
LoadDB(frame->GetDocPath(L"examples/tutorial.cts"));
if (lang.Len() == 2 && !LoadDB(frame->GetDocPath(L"examples/tutorial-" + lang + ".cts"))[0]) {
return;
}

LoadDB(frame->GetDocPath(L"examples/tutorial.cts"));
}

void LoadOpRef() { LoadDB(frame->GetDocPath(L"examples/operation-reference.cts")); }
Expand Down

0 comments on commit d0e582a

Please sign in to comment.