summaryrefslogtreecommitdiff
path: root/wikipedia/models/utils/locale_utils.js
blob: 71d177a0de67b054d5347ae947ad023957bf44e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;


function getSubdirectoryWithLocale(theDir) {

    let locales = GLib.get_language_names();
    let dir = Gio.File.new_for_path(theDir);
    let localeSegment = 'C';

    for(let i=0; i<locales.length; i++) {
        let currLocale = dir.get_child(locales[i]);
        if(currLocale.query_exists(null)) {
            localeSegment = locales[i];
            break;
        }
    }
    return theDir + localeSegment + '/';
}