Sha256: cda84fde9c3349857941797bd97331ac8c222226092e5b510c85a894143411a3
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
require "redmine/generators/plugin_name_attribute" Rails::Generators.lookup %w(rails:model) module Redmine module Generators class TranslationGenerator < Rails::Generators::ModelGenerator include PluginNameAttribute class_option :lang, type: :string, default: "en", desc: "The language for translations" remove_hook_for :orm def add_translations translation "label_#{singular_table_name}", human_name translation "label_#{singular_table_name}_plural", plural_name.capitalize translation "label_#{singular_table_name}_new", "New #{human_name}" translation "label_#{singular_table_name}_edit", "Edit #{human_name}" translation "label_#{singular_table_name}_created", "#{human_name} was successfully created." translation "label_#{singular_table_name}_updated", "#{human_name} was successfully updated." translation "label_#{singular_table_name}_destroyed", "#{human_name} was successfully deleted." attributes.each do |attribute| translation "field_#{attribute.name}", attribute.human_name end end private def translation(key, value, lang = options[:lang]) log :translation, "#{lang}: #{key}" locale_path = "config/locales/#{lang}.yml" trans = " #{key}: \"#{value}\"\n" sentinel = "#{lang}:\n" in_root do inject_into_file locale_path, trans, after: sentinel, verbose: false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redmine-generators-0.0.1 | lib/redmine/generators/translation_generator.rb |