Merge branch 'v2.0'
This commit is contained in:
commit
fca479f675
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"خدمة أل يو أر ل",
|
||||
"yubikey2fUserCanRemoveKey":"Allow user to remove Yubikey",
|
||||
"zeroConfExplanations":"لا يحتوي الخادم على إعدادات. استخدام قالب لحفظ الأول"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"Service URL",
|
||||
"yubikey2fUserCanRemoveKey":"Allow user to remove Yubikey",
|
||||
"zeroConfExplanations":"Server has no configuration. Use template to save the first."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"Service URL",
|
||||
"yubikey2fUserCanRemoveKey":"Allow user to remove Yubikey",
|
||||
"zeroConfExplanations":"Server has no configuration. Use template to save the first."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"URL del servizio",
|
||||
"yubikey2fUserCanRemoveKey":"Autorizza l'utente a rimuovere la Yubikey",
|
||||
"zeroConfExplanations":"Il server non ha alcuna configurazione. Utilizza il modello per salvare il primo."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"URL usługi",
|
||||
"yubikey2fUserCanRemoveKey":"Pozwól użytkownikowi usunąć Yubikey",
|
||||
"zeroConfExplanations":"Serwer nie ma konfiguracji. Użyj szablonu, aby zapisać pierwszy."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"Servis URL'si",
|
||||
"yubikey2fUserCanRemoveKey":"Yubikey'i kaldırmak için kullanıcıya izin ver",
|
||||
"zeroConfExplanations":"Sunucunun yapılandırması yok. Şimdi bir tane kaydetmek için şablonu kullanın."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"Dịch vụ URL",
|
||||
"yubikey2fUserCanRemoveKey":"Allow user to remove Yubikey",
|
||||
"zeroConfExplanations":"Máy chủ không có cấu hình. Sử dụng mẫu để lưu đầu tiên. "
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"Service URL",
|
||||
"yubikey2fUserCanRemoveKey":"Allow user to remove Yubikey",
|
||||
"zeroConfExplanations":"Server has no configuration. Use template to save the first."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1211,4 +1211,4 @@
|
|||
"yubikey2fUrl":"服務 URL",
|
||||
"yubikey2fUserCanRemoveKey":"允許使用者移除 Yubikey",
|
||||
"zeroConfExplanations":"伺服器未設定。使用飯本來儲存第一個。"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,37 @@
|
|||
use strict;
|
||||
use JSON;
|
||||
use Getopt::Long;
|
||||
my ( $portal, $modify, $help, $delete );
|
||||
my ( $portal, $modify, $help, $delete, $reorder );
|
||||
my $json =
|
||||
JSON->new->utf8->pretty()->canonical()->space_before(0)->space_after(0);
|
||||
|
||||
GetOptions(
|
||||
"portal|p" => \$portal,
|
||||
"modify|m" => \$modify,
|
||||
"delete|d" => \$delete,
|
||||
"help|h" => \$help,
|
||||
"portal|p" => \$portal,
|
||||
"modify|m" => \$modify,
|
||||
"delete|d" => \$delete,
|
||||
"reorder|r" => \$reorder,
|
||||
"help|h" => \$help,
|
||||
);
|
||||
usage() if $help or !@ARGV;
|
||||
my $key = shift @ARGV or usage();
|
||||
my $enText = shift @ARGV or $delete or usage();
|
||||
usage() if $help or ( !@ARGV and !$reorder );
|
||||
my $key = shift @ARGV;
|
||||
my $enText = shift @ARGV;
|
||||
my $frText = shift(@ARGV) || $enText;
|
||||
|
||||
# Check args
|
||||
usage() if $delete and $modify;
|
||||
if ($key) {
|
||||
usage() if $reorder;
|
||||
if ($delete) {
|
||||
usage() if $enText;
|
||||
}
|
||||
else {
|
||||
usage() unless $enText;
|
||||
}
|
||||
}
|
||||
else {
|
||||
usage() unless $reorder;
|
||||
}
|
||||
|
||||
# Main
|
||||
my $wdir =
|
||||
'lemonldap-ng-'
|
||||
|
@ -36,19 +52,19 @@ for my $lang (@langs) {
|
|||
close $file;
|
||||
}
|
||||
my $jsonObj = $json->decode($content);
|
||||
if ( !$jsonObj->{$key} and $delete ) {
|
||||
print STDERR "$key does not exist, aborting deletion\n";
|
||||
usage();
|
||||
}
|
||||
elsif ( $jsonObj->{$key} and $modify ) {
|
||||
print STDERR "$key already exists, aborting\n";
|
||||
usage();
|
||||
}
|
||||
if ($delete) {
|
||||
delete $jsonObj->{$key};
|
||||
}
|
||||
else {
|
||||
$jsonObj->{$key} = ( $lang eq 'fr.json' ? $frText : $enText );
|
||||
if ($key) {
|
||||
if ( $jsonObj->{$key} xor( $delete or $modify ) ) {
|
||||
print STDERR ( $jsonObj->{$key}
|
||||
? "key already exists\n"
|
||||
: "key doesn't exit\n" );
|
||||
usage();
|
||||
}
|
||||
if ($delete) {
|
||||
delete $jsonObj->{$key};
|
||||
}
|
||||
else {
|
||||
$jsonObj->{$key} = ( $lang eq 'fr.json' ? $frText : $enText );
|
||||
}
|
||||
}
|
||||
$content = $json->encode($jsonObj);
|
||||
$content =~ s/\n\s+/\n/sg;
|
||||
|
@ -65,8 +81,11 @@ Usage:
|
|||
$0 <option> key enText <frText>
|
||||
|
||||
Options:
|
||||
--portal -p: add entry in portal translation instead of manager
|
||||
--modify -m: modify an existing entry
|
||||
--portal -p: add entry in portal translation instead of manager
|
||||
--modify -m: modify an existing entry
|
||||
--delete -d: delete an existing key
|
||||
--reorder -r: reorder files
|
||||
--help -h: display this
|
||||
EOT
|
||||
exit( $help ? 0 : 1 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue