-
Notifications
You must be signed in to change notification settings - Fork 0
/
gettext.cake
45 lines (44 loc) · 2.23 KB
/
gettext.cake
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
Task("GeneratePot")
.Does(() =>
{
var dirs = $"-s .{sep}{projectName}.Shared";
foreach (var dir in new []{ $"{projectName}.GNOME", $"{projectName}.WinUI" })
{
if (DirectoryExists(dir))
{
dirs = $"{dirs} -s .{sep}{dir}";
}
}
StartProcess($"GetText.Extractor{(IsRunningOnWindows() ? ".exe" : "")}", new ProcessSettings {
Arguments = $"-o {dirs} -as \"_\" -ad \"_p\" -ap \"_n\" -adp \"_pn\" -t .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot"
});
if (IsRunningOnWindows())
{
StartProcess("powershell", new ProcessSettings {
Arguments = $"-Command \"xgettext --from-code=UTF-8 --add-comments --keyword=_ --keyword=C_:1c,2 -o .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot -j .{sep}{projectName}.GNOME{sep}Blueprints{sep}*.blp\""
});
}
else
{
StartProcess("sh", new ProcessSettings {
Arguments = $"-c \"xgettext --from-code=UTF-8 --add-comments --keyword=_ --keyword=C_:1c,2 -o .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot -j .{sep}{projectName}.GNOME{sep}Blueprints{sep}*.blp\""
});
}
StartProcess("xgettext", new ProcessSettings {
Arguments = $"-o .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot -j .{sep}{projectName}.Shared{sep}{appId}.desktop.in"
});
StartProcess("xgettext", new ProcessSettings {
Arguments = $"-o .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot -j --its .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}metainfo.its .{sep}{projectName}.Shared{sep}{appId}.metainfo.xml.in"
});
});
Task("UpdatePo")
.Does(() =>
{
foreach (var lang in FileReadLines($".{sep}{projectName}.Shared{sep}Resources{sep}po{sep}LINGUAS"))
{
Information($"Updating PO for {lang}...");
StartProcess("msgmerge", new ProcessSettings {
Arguments = $"-U .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{lang}.po .{sep}{projectName}.Shared{sep}Resources{sep}po{sep}{shortName}.pot"
});
}
});