bin/asl-samba-usermod in activesambaldap-0.0.3 vs bin/asl-samba-usermod in activesambaldap-0.0.4

- old
+ new

@@ -1,22 +1,24 @@ #!/usr/bin/env ruby require 'active_samba_ldap' require 'active_samba_ldap/command' +include ActiveSambaLdap::GetTextSupport + argv, opts, options = ActiveSambaLdap::Command.parse_options do |opts, options| options.computer_account = false options.gid = nil opts.banner += " USER_NAME" opts.on("-c", "--[no-]computer-account", - "is a Windows Workstation", - "(otherwise, Windows user)", + _("is a Windows Workstation"), + _("(otherwise, Windows user)"), "(#{options.computer_account})") {|options.computer_account|} - opts.on("-g", "--gid=GID", "gid") {|options.gid|} + opts.on("-g", "--gid=GID", _("gid")) {|options.gid|} end name = nil if argv.size == 1 name = argv.first @@ -39,33 +41,38 @@ ldap_mapping :recommended_classes => [] end options.computer_account = true if /\$$/ =~ name -member_class = options.computer_account ? Computer : User -member_type = member_class.name.downcase +if options.computer_account + member_class = Computer + member_type = _("computer") +else + member_class = User + member_type = _("user") +end if options.computer_account name = name.chomp("$") + "$" end unless member_class.exists?(name) - $stderr.puts "#{member_type} '#{name}' doesn't exist." + $stderr.puts(_("%s doesn't exist: %s") % [member_type, name]) exit 1 end member = member_class.find(name) unless Process.uid.zero? - password = ActiveSambaLdap::Command.read_password("Enter your password: ") + password = ActiveSambaLdap::Command.read_password(_("Enter your password: ")) auth_class = Class.new(ActiveSambaLdap::Base) config = ActiveSambaLdap::Base.configurations["reference"] begin auth_class.establish_connection(config.merge(:bind_dn => member.dn, :password => password, :allow_anonymous => false)) rescue ActiveLdap::AuthenticationError - $stderr.puts "password isn't match" + $stderr.puts(_("password isn't match.")) exit 1 ensure auth_class.remove_connection end end