[asl-commit] ActiveSambaLdap (trunk) r106:
null at cozmixng.org
null at cozmixng.org
Fri Sep 7 23:00:29 EDT 2007
retro 2007-09-08 12:00:28 +0900 (Sat, 08 Sep 2007)
New Revision: 106
Added files:
trunk/lib/active_samba_ldap/get_text_support.rb
Modified files:
trunk/Rakefile
trunk/lib/active_samba_ldap.rb
trunk/lib/active_samba_ldap/base.rb
trunk/lib/active_samba_ldap/command.rb
trunk/lib/active_samba_ldap/configuration.rb
trunk/lib/active_samba_ldap/entry.rb
trunk/lib/active_samba_ldap/samba_group_entry.rb
trunk/rails/plugin/active_samba_ldap/init.rb
Log:
Modified: trunk/lib/active_samba_ldap/samba_group_entry.rb (+1 -1)
===================================================================
--- trunk/lib/active_samba_ldap/samba_group_entry.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/samba_group_entry.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -135,7 +135,7 @@
elsif TYPES.values.include?(type.to_i)
# pass
else
- raise ArgumentError, "invalid type: #{type}"
+ raise ArgumentError, _("invalid type: %s") % type
end
self.samba_group_type = type.to_s
end
Modified: trunk/Rakefile (+30 -0)
===================================================================
--- trunk/Rakefile 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/Rakefile 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -139,3 +139,33 @@
rm_f project.bin_files.collect {|f| f.sub(/^bin#{File::SEPARATOR}/, '')}
end
end
+
+
+desc "Update *.po/*.pot files and create *.mo from *.po files"
+task :gettext => ["gettext:po:update", "gettext:mo:create"]
+
+namespace :gettext do
+ desc "Setup environment for GetText"
+ task :environment do
+ require "gettext/utils"
+ end
+
+ namespace :po do
+ desc "Update po/pot files (GetText)"
+ task :update => "gettext:environment" do
+ files = Dir.glob("{lib,rails}/**/*.rb")
+ GetText.update_pofiles("active-samba-ldap",
+ files,
+ "Ruby/ActiveSambaLdap #{ActiveSambaLdap::VERSION}")
+ end
+ end
+
+ namespace :mo do
+ desc "Create *.mo from *.po (GetText)"
+ task :create => "gettext:environment" do
+ GetText.create_mofiles(false)
+ end
+ end
+end
+
+task(:gem).prerequisites.unshift("gettext:mo:create")
Modified: trunk/lib/active_samba_ldap.rb (+2 -1)
===================================================================
--- trunk/lib/active_samba_ldap.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -8,7 +8,7 @@
end
end
-required_active_ldap_version = ">= 0.8.2"
+required_active_ldap_version = ">= 0.8.3.1"
require_gem_if_need.call("active_ldap", "ruby-activeldap",
required_active_ldap_version)
@@ -17,6 +17,7 @@
end
require 'active_samba_ldap/version'
+require 'active_samba_ldap/get_text_support'
require 'active_samba_ldap/base'
require "active_samba_ldap/configuration"
require 'active_samba_ldap/populate'
Modified: trunk/lib/active_samba_ldap/entry.rb (+1 -1)
===================================================================
--- trunk/lib/active_samba_ldap/entry.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/entry.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -36,7 +36,7 @@
prefixes = [prefix]
ou.split(/\s*,\s*/).reverse_each do |entry|
name, value = entry.split(/\s*=\s*/, 2).collect {|x| x.strip}
- raise ArgumentError, "#{ou} must be only ou" if name != "ou"
+ raise ArgumentError, _("%s must be only ou") % ou if name != "ou"
ou_class = Class.new(ActiveSambaLdap::Ou)
ou_class.ldap_mapping :prefix => prefixes.join(',')
prefixes.unshift(entry)
Modified: trunk/lib/active_samba_ldap/base.rb (+19 -17)
===================================================================
--- trunk/lib/active_samba_ldap/base.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/base.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -2,13 +2,14 @@
module ActiveSambaLdap
class Error < StandardError
+ include ActiveSambaLdap::GetTextSupport
end
class RequiredVariableIsNotSet < Error
attr_reader :name
def initialize(name)
@name = name
- super("required variable '#{name}' is not set")
+ super(_("required variable is not set: %s") % name)
end
end
@@ -16,7 +17,7 @@
attr_reader :names
def initialize(names)
@names = names
- super("required variables '#{names.join(', ')}' are not set")
+ super(_("required variables are not set: %s") % names.join(', '))
end
end
@@ -24,7 +25,7 @@
attr_reader :number
def initialize(number)
@number = number
- super("uid number '#{@number}' already exists")
+ super(_("uid number already exists: %s") % number)
end
end
@@ -32,7 +33,7 @@
attr_reader :name
def initialize(name)
@name = name
- super("group '#{@name}' doesn't exist")
+ super(_("group doesn't exist: %s") % name)
end
end
@@ -40,7 +41,7 @@
attr_reader :number
def initialize(number)
@number = number
- super("gid number '#{@number}' already exists")
+ super(_("gid number already exists: %s") % number)
end
end
@@ -48,7 +49,7 @@
attr_reader :number
def initialize(number)
@number = number
- super("gid number '#{@number}' doesn't exist")
+ super(_("gid number doesn't exist: %s") % number)
end
end
@@ -56,7 +57,7 @@
attr_reader :number
def initialize(number)
@number = number
- super("sambaSID attribute doesn't exist for gid number '#{@number}'")
+ super(_("sambaSID attribute doesn't exist for gid number '%s'") % number)
end
end
@@ -65,9 +66,9 @@
def initialize(group, members)
@group = group
@members = members
- message = "cannot change primary group from '#{group}' to other group "
- message << "due to no other belonged groups: #{members.join(', ')}"
- super(message)
+ format = _("cannot change primary group from '%s' to other group " \
+ "due to no other belonged groups: %s")
+ super(format % [group, members.join(', ')])
end
end
@@ -76,9 +77,9 @@
def initialize(group, members)
@group = group
@members = members
- message = "cannot destroy group '#{group}' due to members who belong "
- message << "to the group as primary group: #{members.join(', ')}"
- super(message)
+ format = _("cannot destroy group '%s' due to members who belong " \
+ "to the group as primary group: %s")
+ super(format % [group, members.join(', ')])
end
end
@@ -88,8 +89,8 @@
@file = file
@location = location
@detail = detail
- super("found invalid configuration format at #{@file}:#{@location}" +
- ": #{@detail}")
+ format = _("found invalid configuration format at %s:%s: %s")
+ super(format % [file, location, detail])
end
end
@@ -99,7 +100,8 @@
@name = name
@value = value
@detail = detail
- super("the value of #{@name} '#{@value.inspect}' is invalid: #{@detail}")
+ format = _("the value of %s '%s' is invalid: %s")
+ super(format % [name, value.inspect, detail])
end
end
@@ -107,7 +109,7 @@
attr_reader :object
def initialize(object)
@object = object
- super("#{@object.inspect} is not Samba available")
+ super(_("%s is not Samba available") % [object.inspect])
end
end
Added: trunk/lib/active_samba_ldap/get_text_support.rb (+12 -0)
===================================================================
--- trunk/lib/active_samba_ldap/get_text_support.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/get_text_support.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -0,0 +1,12 @@
+module ActiveSambaLdap
+ module GetTextSupport
+ class << self
+ def included(base)
+ base.class_eval do
+ include(ActiveLdap::GetText)
+ bindtextdomain("active-samba-ldap")
+ end
+ end
+ end
+ end
+end
Modified: trunk/rails/plugin/active_samba_ldap/init.rb (+15 -3)
===================================================================
--- trunk/rails/plugin/active_samba_ldap/init.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/rails/plugin/active_samba_ldap/init.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -1,6 +1,18 @@
require_library_or_gem 'active_samba_ldap'
ActiveSambaLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
-ActiveSambaLdap::Base.configurations =
- ActiveSambaLdap::Configuration.read(ldap_configuration_file)
-ActiveSambaLdap::Base.establish_connection
+if File.exist?(ldap_configuration_file)
+ ActiveSambaLdap::Base.configurations =
+ ActiveSambaLdap::Configuration.read(ldap_configuration_file)
+ ActiveSambaLdap::Base.establish_connection
+else
+ ActiveLdap::Base.class_eval do
+ format = _("You should run 'script/generator scaffold_active_samba_ldap' " \
+ "to make %s.")
+ logger.error(format % ldap_configuration_file)
+ end
+end
+
+class ActionView::Base
+ include ActiveLdap::Helper
+end
Modified: trunk/lib/active_samba_ldap/command.rb (+8 -6)
===================================================================
--- trunk/lib/active_samba_ldap/command.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/command.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -5,6 +5,8 @@
module ActiveSambaLdap
module Command
+ include ActiveSambaLdap::GetTextSupport
+
module_function
def parse_options(argv=nil)
argv ||= ARGV.dup
@@ -13,22 +15,22 @@
opts = OptionParser.new do |opts|
yield(opts, options)
- opts.separator ""
- opts.separator "Common options:"
+ opts.separator("")
+ opts.separator(_("Common options:"))
opts.on_tail("--config=CONFIG",
- "Specify configuration file",
- "Default configuration files:",
+ _("Specify configuration file"),
+ _("Default configuration files:"),
*configuration_files.collect {|x| " #{x}"}) do |file|
configuration_files << file
end
- opts.on_tail("-h", "--help", "Show this message") do
+ opts.on_tail("-h", "--help", _("Show this message")) do
puts opts
exit
end
- opts.on_tail("--version", "Show version") do
+ opts.on_tail("--version", _("Show version")) do
puts VERSION
exit
end
Modified: trunk/lib/active_samba_ldap/configuration.rb (+3 -1)
===================================================================
--- trunk/lib/active_samba_ldap/configuration.rb 2007-09-08 11:30:57 +09:00 (rev 105)
+++ trunk/lib/active_samba_ldap/configuration.rb 2007-09-08 12:00:28 +09:00 (rev 106)
@@ -78,6 +78,8 @@
end
class Private
+ include ActiveSambaLdap::GetTextSupport
+
VARIABLES = %w(base host port scope bind_dn
password method allow_anonymous
@@ -305,7 +307,7 @@
types = AVAILABLE_HASH_TYPES.collect {|x| x.inspect}.join(", ")
raise InvalidConfigurationValueError.new("password_hash_type",
type,
- "must be in #{types}")
+ _("must be in %s") % types)
end
end
More information about the asl-commit
mailing list