store language file paths relatively

This commit is contained in:
itsmattkc
2019-02-09 16:15:06 -08:00
parent 6ee7153f4a
commit 6dd54019a0
3 changed files with 18 additions and 7 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ public:
int encoding_codec,
VideoCodecParams& iparams);
void accept();
public slots:
virtual void accept() override;
private:
VideoCodecParams& params;
+4 -1
View File
@@ -392,11 +392,14 @@ void PreferencesDialog::setup_ui() {
if (translation_dir.exists()) {
QStringList translation_files = translation_dir.entryList({"*.qm"}, QDir::Files | QDir::NoDotAndDotDot);
for (int i=0;i<translation_files.size();i++) {
// get path of translation relative to the application path
QString locale_full_path = translation_dir.filePath(translation_files.at(i));
QString locale_relative_path = QDir(get_app_dir()).relativeFilePath(locale_full_path);
QFileInfo locale_file(translation_files.at(i));
QString locale_file_basename = locale_file.baseName();
QString locale_str = locale_file_basename.mid(locale_file_basename.lastIndexOf('_')+1);
language_combobox->addItem(QLocale(locale_str).nativeLanguageName(), locale_full_path);
language_combobox->addItem(QLocale(locale_str).nativeLanguageName(), locale_relative_path);
if (config.language_file == locale_full_path) {
language_combobox->setCurrentIndex(language_combobox->count() - 1);
+12 -5
View File
@@ -207,11 +207,18 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) :
config.language_file :
runtime_config.external_translation_file;
if (!language_file.isEmpty()
&& QFileInfo::exists(language_file)) {
QTranslator* translator = new QTranslator(this);
translator->load(language_file);
QApplication::installTranslator(translator);
if (!language_file.isEmpty()) {
// translation files are stored relative to app path (see GitHub issue #454)
QString full_language_path = QDir(get_app_dir()).filePath(language_file);
if (QFileInfo::exists(full_language_path)) {
QTranslator* translator = new QTranslator(this);
translator->load(full_language_path);
QApplication::installTranslator(translator);
} else {
qWarning() << "Failed to load translation file" << full_language_path << ". No language will be loaded.";
}
}
alloc_panels(this);