store language file paths relatively
This commit is contained in:
@@ -14,7 +14,8 @@ public:
|
||||
int encoding_codec,
|
||||
VideoCodecParams& iparams);
|
||||
|
||||
void accept();
|
||||
public slots:
|
||||
virtual void accept() override;
|
||||
private:
|
||||
VideoCodecParams& params;
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user