]> git.proxmox.com Git - pve-manager-legacy.git/blame - po/jsgettext.pl
updated Slovenian translations
[pve-manager-legacy.git] / po / jsgettext.pl
CommitLineData
660fe2ae
DM
1#!/usr/bin/perl
2
3use strict;
4use Time::Local;
5use PVE::Tools;
6use Locale::PO;
7
8my $dir = shift;
9
10
11die "no such directory\n" if ! -d $dir;
12
13my $sources = [];
14
15my $findcmd = ['find', $dir, '-name', '*.js'];
16PVE::Tools::run_command($findcmd, outfunc => sub {
17 my $line = shift;
18 next if $line =~ m|/pvemanagerlib.js$|;
19 push @$sources, $line;
20});
21
22my $filename = "messages.pot";
23
24my $header = <<__EOD;
25SOME DESCRIPTIVE TITLE.
26Copyright (C) 20011 Proxmox Server Solutions GmbH
27This file is distributed under the same license as the pve-manager package.
28Proxmox Support Team <support\@proxmox.com>, 2011.
29__EOD
30
31my $ctime = scalar localtime;
32
33my $href = {};
34my $po = new Locale::PO(-msgid=> '',
35 -comment=> $header,
36 -fuzzy=> 1,
37 -msgstr=>
38 "Project-Id-Version: pve-manager 2.0\\n" .
39 "Report-Msgid-Bugs-To: <support\@proxmox.com>\\n" .
40 "POT-Creation-Date: $ctime\\n" .
41 "PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\\n" .
42 "Last-Translator: FULL NAME <EMAIL\@ADDRESS>\\n" .
43 "Language-Team: LANGUAGE <support\@proxmox.com>\\n" .
44 "MIME-Version: 1.0\\n" .
45 "Content-Type: text/plain; charset=CHARSET\\n" .
46 "Content-Transfer-Encoding: 8bit\\n");
47
48$href->{''} = $po;
49
50sub extract_msg {
51 my ($filename, $linenr, $line) = @_;
52
53 my $text;
54 if ($line =~ m/\Wgettext\s*\("((?:[^"\\]++|\\.)*+)"\)/) {
55 $text = $1;
56 } elsif ($line =~ m/\Wgettext\s*\('((?:[^'\\]++|\\.)*+)'\)/) {
57 $text = $1;
58 } else {
59 die "can't extract gettext message in '$filename' line $linenr\n";
60 }
61
62 my $ref = "$filename:$linenr";
63
64 if (my $po = $href->{$text}) {
65 $po->reference($po->reference() . " $ref");
66 return;
67 }
68
69 my $po = new Locale::PO(-msgid=> $text, -reference=> $ref, -msgstr=> '');
70 $href->{$text} = $po;
71}
72
73
74foreach my $s (@$sources) {
75 open(SRC, $s) || die "unable to open file '$s' - $!\n";
76 while(defined(my $line = <SRC>)) {
77 if ($line =~ m/gettext/) {
78 extract_msg($s, $., $line);
79 }
80 }
81 close(SRC);
82}
83
84Locale::PO->save_file_fromhash($filename, $href);
85