QString Paths::doc(QString file, QString locale, bool english_fallback) { if (locale.isEmpty()) { locale = QLocale::system().name(); } QString f = docPath() + "/" + locale + "/" + file; qDebug("Helper:doc: checking '%s'", f.toUtf8().data()); if (QFile::exists(f)) return f; if (locale.indexOf(QRegExp("_[A-Z]+")) != -1) { locale.replace(QRegExp("_[A-Z]+"), ""); f = docPath() + "/" + locale + "/" + file; qDebug("Helper:doc: checking '%s'", f.toUtf8().data()); if (QFile::exists(f)) return f; } if (english_fallback) { f = docPath() + "/en/" + file; return f; } return QString::null; }
QString TPaths::doc(const QString& file, QString locale, bool english_fallback) { if (locale.isEmpty()) { locale = QLocale::system().name(); } QString f = docPath() + "/" + locale + "/" + file; if (QFile::exists(f)) return f; if (locale.indexOf(QRegExp("_[A-Z]+")) >= 0) { locale.replace(QRegExp("_[A-Z]+"), ""); f = docPath() + "/" + locale + "/" + file; if (QFile::exists(f)) return f; } if (english_fallback) { f = docPath() + "/en/" + file; return f; } return QString::null; }