added path search system for translations
This commit is contained in:
@@ -384,17 +384,24 @@ void PreferencesDialog::setup_ui() {
|
||||
language_combobox->addItem(QLocale::languageToString(QLocale("en-US").language()));
|
||||
|
||||
// add languages from file
|
||||
QDir translation_dir(QApplication::applicationDirPath().append("/ts"));
|
||||
QStringList translation_files = translation_dir.entryList({"*.qm"}, QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (int i=0;i<translation_files.size();i++) {
|
||||
QString locale_full_path = translation_dir.filePath(translation_files.at(i));
|
||||
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);
|
||||
QList<QString> translation_paths = get_language_paths();
|
||||
|
||||
if (config.language_file == locale_full_path) {
|
||||
language_combobox->setCurrentIndex(language_combobox->count() - 1);
|
||||
// iterate through all language search paths
|
||||
for (int j=0;j<translation_paths.size();j++) {
|
||||
QDir translation_dir(translation_paths.at(j));
|
||||
if (translation_dir.exists()) {
|
||||
QStringList translation_files = translation_dir.entryList({"*.qm"}, QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (int i=0;i<translation_files.size();i++) {
|
||||
QString locale_full_path = translation_dir.filePath(translation_files.at(i));
|
||||
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);
|
||||
|
||||
if (config.language_file == locale_full_path) {
|
||||
language_combobox->setCurrentIndex(language_combobox->count() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,3 +44,12 @@ QString get_file_hash(const QString& filename) {
|
||||
QString cache_file = filename.mid(filename.lastIndexOf('/')+1) + QString::number(file_info.size()) + QString::number(file_info.lastModified().toMSecsSinceEpoch());
|
||||
return QCryptographicHash::hash(cache_file.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
|
||||
QList<QString> get_language_paths() {
|
||||
QList<QString> language_paths;
|
||||
language_paths.append(get_app_dir() + "/ts");
|
||||
language_paths.append(get_app_dir() + "/../share/olive-editor/ts");
|
||||
QString env_path(qgetenv("OLIVE_LANG_PATH"));
|
||||
if (!env_path.isEmpty()) language_paths.append(env_path);
|
||||
return language_paths;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ QString get_app_dir();
|
||||
QString get_data_path();
|
||||
QString get_config_path();
|
||||
QList<QString> get_effects_paths();
|
||||
QList<QString> get_language_paths();
|
||||
|
||||
// generate hash algorithm used to uniquely identify files
|
||||
QString get_file_hash(const QString& filename);
|
||||
|
||||
@@ -43,6 +43,11 @@ int main(int argc, char *argv[]) {
|
||||
"\t--no-debug\t\tDisable internal debug log and output directly to console\n"
|
||||
"\t--disable-blend-modes\tDisable shader-based blending for older GPUs\n"
|
||||
"\t--translation <file>\tSet an external language file to use\n"
|
||||
"\n"
|
||||
"Environment Variables:\n"
|
||||
"\tOLIVE_EFFECTS_PATH\tSpecify a path to search for GLSL shader effects\n"
|
||||
"\tFREI0R_PATH\t\tSpecify a path to search for Frei0r effects\n"
|
||||
"\tOLIVE_LANG_PATH\t\tSpecify a path to search for translation files\n"
|
||||
"\n", argv[0]);
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {
|
||||
|
||||
Reference in New Issue
Block a user