Skip to content

Commit

Permalink
initial gem version
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Jan 14, 2011
1 parent b3747ad commit 8c3854c
Show file tree
Hide file tree
Showing 7 changed files with 1,082 additions and 510 deletions.
8 changes: 8 additions & 0 deletions README.textile
Expand Up @@ -37,6 +37,14 @@ Then run:


<pre>$ bundle install</pre> <pre>$ bundle install</pre>


Then run:

<pre>$ rails g localized_language_select:locales</pre>

In order to copy locale files to your Rails config/locales dir. Note: you can specify which locales using the @--locales@ option, which takes a list of locales.

<pre>$ rails g localized_language_select:locales --locales da en fr</pre>

h2. Usage example h2. Usage example


<pre> <pre>
Expand Down
@@ -0,0 +1,38 @@
# require 'rails/generators/base'
# require 'sugar-high/array'
# require 'active_support/inflector'
# require 'rails3_artifactor'
# require 'logging_assist'

module LocalizedLanguageSelect
module Generators
class LocaleGenerator < Rails::Generators::Base
desc "Copy locale files"

class_option :locales, :type => :array, :default => ['all'], :desc => 'locales to generate for'

source_root File.dirname(__FILE__)

def main_flow
copy_locales
end

protected

def supported_locales
[:en, :da]
end

def locales
return supported_locales if options[:locales].include? 'all'
options[:locales].map(&:to_sym) & supported_locales
end

def copy_locales
locales.each do |locale|
copy_file "../../../../locale/#{locale}.yml", "config/locales/languages.#{locale}.yml"
end
end
end
end
end
3 changes: 3 additions & 0 deletions lib/localized_language_select.rb
Expand Up @@ -18,6 +18,9 @@
# The code borrows heavily from the LocalizedCountrySelect plugin. # The code borrows heavily from the LocalizedCountrySelect plugin.
# See http://github.com/karmi/localized_country_select # See http://github.com/karmi/localized_country_select
# #

require 'localized_language_select/i18n'

module LocalizedLanguageSelect module LocalizedLanguageSelect
class << self class << self
# Returns array with codes and localized language names (according to <tt>I18n.locale</tt>) # Returns array with codes and localized language names (according to <tt>I18n.locale</tt>)
Expand Down
19 changes: 19 additions & 0 deletions lib/localized_language_select/i18n.rb
@@ -0,0 +1,19 @@
# encoding: utf-8

# module LocalizedLanguageSelect
# module I18n
# DEFAULT_SCOPE = [:languages].freeze
# DEFAULT_VALUES = YAML.load_file(File.expand_path("../../../locale/en.yml", __FILE__))["en"]["languages"].freeze
#
# class << self
# def translate(*args)
# key = args.shift.to_sym
# options = args.extract_options!
# options.reverse_merge!(:default => DEFAULT_VALUES[key])
# options[:scope] = [DEFAULT_SCOPE, options[:scope]].flatten.compact
# ::I18n.translate(key, *(args << options))
# end
# alias :t :translate
# end
# end
# end

0 comments on commit 8c3854c

Please sign in to comment.