Permalink
Browse files

initial gem version

  • Loading branch information...
kristianmandrup committed Jan 14, 2011
1 parent b3747ad commit 8c3854c113cb915e78f11c09beec73d38a05d25a
View
@@ -37,6 +37,14 @@ Then run:
<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
<pre>
@@ -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
@@ -18,6 +18,9 @@
# The code borrows heavily from the LocalizedCountrySelect plugin.
# See http://github.com/karmi/localized_country_select
#
+
+require 'localized_language_select/i18n'
+
module LocalizedLanguageSelect
class << self
# Returns array with codes and localized language names (according to <tt>I18n.locale</tt>)
@@ -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
Oops, something went wrong.

0 comments on commit 8c3854c

Please sign in to comment.