Class: Aginx::Generators::LocaleGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Aginx::Generators::LocaleGenerator
- Defined in:
- lib/aginx/generators/aginx/locale/locale_generator.rb
Instance Method Summary collapse
-
#create_en_locales ⇒ Object
创建中文本地化.
-
#create_zh_locales ⇒ Object
创建中文本地化.
- #init ⇒ Object
Instance Method Details
#create_en_locales ⇒ Object
创建中文本地化
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aginx/generators/aginx/locale/locale_generator.rb', line 13 def create_en_locales yml_code = <<-EOF #{@model_name.underscore}: #{@model_name} EOF inject_into_file( 'config/locales/activerecord.en.yml', before: " # Do not delete this line for agi_scaffold model") {yml_code} yml_code = " #{@model_name.underscore}:\n" yml_code << @en_locales.map{|l| " #{l}: #{l.camelize}"}.join("\n") yml_code << "\n" inject_into_file( 'config/locales/activerecord.en.yml', before: " # Do not delete this line for agi_scaffold attributes") {yml_code} yml_code = <<-EOF #{@model_name.pluralize.underscore}: index: title: #{@model_name} edit: title: Edit #{@model_name} new: title: New #{@model_name} create: success: Create #{@model_name} success EOF inject_into_file( 'config/locales/admin.en.yml', before: " # Do not delete this line for agi_scaffold") {yml_code} end |
#create_zh_locales ⇒ Object
创建中文本地化
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/aginx/generators/aginx/locale/locale_generator.rb', line 48 def create_zh_locales yml_code = <<-EOF #{@model_name.underscore}: #{[:model_locale]} EOF inject_into_file( 'config/locales/activerecord.zh-CN.yml', before: " # Do not delete this line for agi_scaffold model") {yml_code} yml_code = " #{@model_name.underscore}:\n" yml_code << @zh_locales.map{|l| " #{l[0]}: #{l[1]}"}.join("\n") yml_code << "\n" inject_into_file( 'config/locales/activerecord.zh-CN.yml', before: " # Do not delete this line for agi_scaffold attributes") {yml_code} yml_code = <<-EOF #{@model_name.pluralize.underscore}: index: title: #{[:model_locale]} edit: title: 编辑 #{[:model_locale]} new: title: 新建 #{[:model_locale]} create: success: 创建 #{[:model_locale]} 成功 EOF inject_into_file( 'config/locales/admin.zh-CN.yml', before: " # Do not delete this line for agi_scaffold") {yml_code} end |
#init ⇒ Object
8 9 10 |
# File 'lib/aginx/generators/aginx/locale/locale_generator.rb', line 8 def init prepare end |