~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-2066

« back to all changes in this revision

Viewing changes to plugins/language/language-plugin.cpp

  • Committer: Bileto Bot
  • Author(s): Jonas G. Drange
  • Date: 2016-09-30 13:48:06 UTC
  • mfrom: (1720.3.7 path-fixes)
  • Revision ID: ci-train-bot@canonical.com-20160930134806-tir714ireb8xzaau
uses XDG_DATA_DIRS where applicable to enable USS to find files and folders on snappy-based systems (LP: #1629009)

Approved by: Alberto Mardegan, Ken VanDine, Lukáš Tinkl, system-apps-ci-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * You should have received a copy of the GNU General Public License along
18
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
 */
 
20
#include <QStandardPaths>
20
21
#include <QtDebug>
21
22
#include "language-plugin.h"
22
23
#include "keyboard-layout.h"
24
25
#include <act/act.h>
25
26
#include <unicode/locid.h>
26
27
 
27
 
#define LANGUAGE2LOCALE "/usr/share/language-tools/language2locale"
 
28
#define LANGUAGE2LOCALE "language-tools/language2locale"
28
29
 
29
30
static const char * const LOCALE_BLACKLIST[] = {
30
31
    "C",
208
209
        QString language(languageLocale.locale.getLanguage());
209
210
 
210
211
        if (!likelyLocaleForLanguage.contains(language)) {
211
 
            QProcess likelyProcess;
212
 
            likelyProcess.start(LANGUAGE2LOCALE,
213
 
                                QStringList(language),
214
 
                                QIODevice::ReadOnly);
215
 
            likelyProcess.waitForFinished();
216
 
            QString likelyLocale(likelyProcess.readAllStandardOutput());
217
 
            likelyLocale = likelyLocale.left(likelyLocale.indexOf('.'));
218
 
            likelyLocaleForLanguage.insert(language, likelyLocale.trimmed());
 
212
            QString l2lPath = QStandardPaths::locate(
 
213
                QStandardPaths::GenericDataLocation, LANGUAGE2LOCALE
 
214
            );
 
215
            if (l2lPath.isEmpty()) {
 
216
                qWarning() << "Could not find language2locale file.";
 
217
            } else {
 
218
                QProcess likelyProcess;
 
219
                likelyProcess.start(l2lPath, QStringList(language),
 
220
                                    QIODevice::ReadOnly);
 
221
                likelyProcess.waitForFinished();
 
222
                QString likelyLocale(likelyProcess.readAllStandardOutput());
 
223
                likelyLocale = likelyLocale.left(likelyLocale.indexOf('.'));
 
224
                likelyLocaleForLanguage.insert(language,
 
225
                                               likelyLocale.trimmed());
 
226
            }
219
227
        }
220
228
 
221
229
        languageLocale.likely = likelyLocaleForLanguage[language] ==