Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3747ad
commit 8c3854c
Showing
7 changed files
with
1,082 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
lib/generators/localized_language_select/locales/locales_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.