forked from euroelessar/qutim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translations.qbs
66 lines (58 loc) · 2.22 KB
/
translations.qbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import qbs.base 1.0
import qbs.fileinfo as FileInfo
Product {
type: "installed_content"
Depends { name: "qutimscope" }
property string shareDir: qutimscope.shareDir
property string lconvertPath: qt.core.binPath + "/lconvert"
property string lreleasePath: qt.core.binPath + "/lrelease"
Depends { name: "qt.core" }
Group {
fileTags: [ "po" ]
prefix: "translations/modules/"
files: "*.po"
recursive: true
}
Rule {
inputs: [ "po" ]
Artifact {
fileTags: [ "qutim_ts" ]
fileName: "GeneratedFiles/" + input.baseDir + "/" + input.fileName.replace(/.po$/, ".ts")
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.executable = product.lconvertPath;
cmd.sourceCode = function() {
var p = new Process();
if (p.exec(executable, [ input.fileName, '-of', "ts" ]) !== 0)
throw "Cannot execute " + executable;
var content = p.readAll().replace(/<message>/g, '<message utf8="true">');
var file = new TextFile(output.fileName, TextFile.WriteOnly);
file.write(content);
file.close();
}
var moduleName = FileInfo.fileName(FileInfo.path(output.fileName));
cmd.description = 'converting to ' + moduleName + "/" + FileInfo.fileName(output.fileName);
cmd.highlight = 'codegen';
return cmd;
}
}
Rule {
inputs: [ "qutim_ts" ]
Artifact {
fileTags: [ "installed_content" ]
fileName: {
var language = input.baseName;
var module = FileInfo.fileName(input.baseDir);
return product.shareDir + "/languages/" + language + "/" + module + ".qm";
}
}
prepare: {
var cmd = new Command(product.lreleasePath, [ '-silent', input.fileName, '-qm', output.fileName ]);
var moduleName = FileInfo.fileName(FileInfo.path(output.fileName));
cmd.description = 'converting to ' + moduleName + "/" + FileInfo.fileName(output.fileName);
cmd.highlight = 'linker';
return cmd;
}
}
}