diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-08-28 18:59:44 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-08-30 15:59:31 +0200 |
commit | c09563fe18c1f29affc3bae6a122824e2ffcb706 (patch) | |
tree | 8db651fd2810767d3ee533e0d29a1e0e9867a0d6 | |
parent | 4515f8152a6a43092995a9314d7d3f5c973bb8e6 (diff) |
Make abouttab read locale specific content if it exists.
-rw-r--r-- | plugingui/abouttab.cc | 31 | ||||
-rw-r--r-- | plugingui/abouttab.h | 5 |
2 files changed, 27 insertions, 9 deletions
diff --git a/plugingui/abouttab.cc b/plugingui/abouttab.cc index 7e330cb..8a8f737 100644 --- a/plugingui/abouttab.cc +++ b/plugingui/abouttab.cc @@ -27,9 +27,32 @@ #include "abouttab.h" #include <version.h> +#include <translation.h> #include "utf8.h" +namespace +{ +std::string getLocalizedFile(const std::string& file) +{ + auto language = Translation::getISO639LanguageName(); + std::string file_localized = file + "." + language; + GUI::Resource resource_localized{file_localized}; + if(resource_localized.valid()) + { + return resource_localized.data(); + } + + GUI::Resource resource{file}; + if(resource.valid()) + { + return resource.data(); + } + + return ""; +} +} + namespace GUI { @@ -60,7 +83,7 @@ std::string AboutTab::getAboutText() " About\n" "=============\n" "\n"); - about_text.append(about.data()); + about_text.append(getLocalizedFile(":../ABOUT")); // Version about_text.append( @@ -78,7 +101,7 @@ std::string AboutTab::getAboutText() " Bugs\n" "=============\n" "\n"); - about_text.append(bugs.data()); + about_text.append(getLocalizedFile(":../BUGS")); // Authors about_text.append( @@ -87,7 +110,7 @@ std::string AboutTab::getAboutText() " Authors\n" "=============\n" "\n"); - about_text.append(UTF8().toLatin1(authors.data())); + about_text.append(UTF8().toLatin1(getLocalizedFile(":../AUTHORS"))); // GPL about_text.append( @@ -96,7 +119,7 @@ std::string AboutTab::getAboutText() " License\n" "=============\n" "\n"); - about_text.append(gpl.data()); + about_text.append(getLocalizedFile(":../COPYING")); return about_text; } diff --git a/plugingui/abouttab.h b/plugingui/abouttab.h index eda23da..ed06b1d 100644 --- a/plugingui/abouttab.h +++ b/plugingui/abouttab.h @@ -49,11 +49,6 @@ private: TextEdit text_edit{this}; int margin{10}; - - Resource about{":../ABOUT"}; - Resource bugs{":../BUGS"}; - Resource authors{":../AUTHORS"}; - Resource gpl{":../COPYING"}; }; } // GUI:: |