Skip to content

Commit

Permalink
GUI - use QLocale's first of uiLanguages to get primary locale
Browse files Browse the repository at this point in the history
This appears to work better with Big Sur.

Also improve locale logging.
  • Loading branch information
samaaron committed Jan 31, 2021
1 parent f26f425 commit f59f58f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/gui/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ int main(int argc, char *argv[])

qRegisterMetaType<SonicPiLog::MultiMessage>("SonicPiLog::MultiMessage");

QString systemLocale = QLocale::system().name();

QString systemLocale = QLocale::system().uiLanguages()[0];

QTranslator qtTranslator;
qtTranslator.load("qt_" + systemLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
Expand Down
11 changes: 10 additions & 1 deletion app/gui/qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,20 @@ MainWindow::MainWindow(QApplication &app, bool i18n, QSplashScreen* splash)

// Throw all stdout into ~/.sonic-pi/log/gui.log
setupLogPathAndRedirectStdOut();

std::cout << "[GUI] - " << std::endl;
std::cout << "[GUI] - " << std::endl;
std::cout << "[GUI] - " << std::endl;
std::cout << "[GUI] - Welcome to the Sonic Pi GUI" << std::endl;
std::cout << "[GUI] - ===========================" << std::endl;
std::cout << "[GUI] - " << std::endl;
std::cout << "[GUI] - " << guiID.toStdString() << std::endl;
std::cout << "[GUI] - locale: " << QLocale::system().uiLanguages()[0].toStdString() << std::endl;

if(i18n) {
std::cout << "[GUI] - translations available " << std::endl;
} else {
std::cout << "[GUI] - translations unavailable (using EN)" << std::endl;
}

// dynamically discover port numbers and then check them this will
// show an error dialogue to the user and then kill the app if any of
Expand Down
2 changes: 1 addition & 1 deletion app/server/ruby/bin/qt-doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
map { |p| File.basename(p).gsub(/sonic-pi-tutorial-(.*?).po/, '\1') }.
sort_by {|n| -n.length}

docs << "\n QString systemLocale = QLocale::system().name();\n\n" unless languages.empty?
docs << "\n QString systemLocale = QLocale::system().uiLanguages()[0];\n\n" unless languages.empty?

# first, try to match all non-default languages (those that aren't "en")
languages.each do |lang|
Expand Down

0 comments on commit f59f58f

Please sign in to comment.