diff --git a/app/controllers/concerns/api/v2/taxonomies_controller.rb b/app/controllers/concerns/api/v2/taxonomies_controller.rb index 75f83e6a99d..7adc3ade1e4 100644 --- a/app/controllers/concerns/api/v2/taxonomies_controller.rb +++ b/app/controllers/concerns/api/v2/taxonomies_controller.rb @@ -31,9 +31,11 @@ module Api::V2::TaxonomiesController param :subnet_ids, Array, N_("Subnet IDs"), :required => false param :parent_id, :number, :desc => N_('Parent ID'), :required => false param :ignore_types, Array, N_("List of resources types that will be automatically associated"), :required => false - resource_name = (param_name == :location) ? 'organization' : 'location' - resource_ids = "#{resource_name}_ids".to_sym - param resource_ids, Array, N_("Associated %{resource} IDs") % { resource: _(resource_name) }, :required => false + if param_name == :location + param :organization_ids, Array, N_("Associated organization IDs"), :required => false + else + param :location_ids, Array, N_("Associated location IDs"), :required => false + end end end diff --git a/app/models/concerns/hostext/ownership.rb b/app/models/concerns/hostext/ownership.rb index 6ea963d19e8..e25131bfc75 100644 --- a/app/models/concerns/hostext/ownership.rb +++ b/app/models/concerns/hostext/ownership.rb @@ -10,7 +10,7 @@ module Ownership validates :owner_type, :inclusion => {:in => OWNER_TYPES, :allow_blank => true, - :message => (_("Owner type needs to be one of the following: %s") % OWNER_TYPES.join(', '))} + :message => (N_("Owner type needs to be one of the following: %s") % OWNER_TYPES.join(', '))} validate :validate_owner validate :owner_taxonomies_match, :if => proc { |host| host.owner.is_a?(User) } end diff --git a/app/models/host/base.rb b/app/models/host/base.rb index 1345ca78a2a..b79ef93f9f6 100644 --- a/app/models/host/base.rb +++ b/app/models/host/base.rb @@ -37,7 +37,7 @@ class Base < ApplicationRecord alias_attribute :hostname, :name - validates :name, :presence => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)} + validates :name, :presence => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => N_(Net::Validations::HOST_REGEXP_ERR_MSG)} validate :host_has_required_interfaces validate :uniq_interfaces_identifiers diff --git a/app/models/host/managed.rb b/app/models/host/managed.rb index 597781da9e7..b9afcb4ade8 100644 --- a/app/models/host/managed.rb +++ b/app/models/host/managed.rb @@ -313,7 +313,7 @@ class Jail < ::Safemode::Jail delegate :require_ip4_validation?, :require_ip6_validation?, :to => :provision_interface validates :architecture_id, :presence => true, :if => proc { |host| host.managed } - validates :root_pass, :length => {:minimum => 8, :message => _('should be 8 characters or more')}, + validates :root_pass, :length => {:minimum => 8, :message => N_('should be 8 characters or more')}, :presence => {:message => N_('should not be blank - consider setting a global or host group default')}, :if => proc { |host| host.managed && !host.image_build? && build? } validates :ptable_id, :presence => {:message => N_("can't be blank unless a custom partition has been defined")}, diff --git a/app/models/hostgroup.rb b/app/models/hostgroup.rb index 619347736a9..794264019ba 100644 --- a/app/models/hostgroup.rb +++ b/app/models/hostgroup.rb @@ -23,7 +23,7 @@ class Hostgroup < ApplicationRecord validates_lengths_from_database :except => [:name] before_destroy EnsureNotUsedBy.new(:hosts) - validates :root_pass, :allow_blank => true, :length => {:minimum => 8, :message => _('should be 8 characters or more')} + validates :root_pass, :allow_blank => true, :length => {:minimum => 8, :message => N_('should be 8 characters or more')} has_many :group_parameters, :dependent => :destroy, :foreign_key => :reference_id, :inverse_of => :hostgroup accepts_nested_attributes_for :group_parameters, :allow_destroy => true include ParameterValidators diff --git a/app/models/nic/interface.rb b/app/models/nic/interface.rb index efe52d49eda..a8dec6d6601 100644 --- a/app/models/nic/interface.rb +++ b/app/models/nic/interface.rb @@ -11,7 +11,7 @@ class Interface < Base before_validation :copy_hostname_from_host, :if => proc { |nic| nic.primary? && nic.hostname.blank? } before_validation :normalize_name - validates :name, :allow_nil => true, :allow_blank => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)} + validates :name, :allow_nil => true, :allow_blank => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => N_(Net::Validations::HOST_REGEXP_ERR_MSG)} validate :name_uniqueness, :if => proc { |i| i.name.present? } diff --git a/app/services/name_generator.rb b/app/services/name_generator.rb index 445acd625e2..777b6860008 100644 --- a/app/services/name_generator.rb +++ b/app/services/name_generator.rb @@ -1,8 +1,8 @@ class NameGenerator GENERATOR_TYPES = { - 'Off' => _('Off'), - 'Random-based' => _('Random-based'), - 'MAC-based' => _('MAC-based'), + 'Off' => N_('Off'), + 'Random-based' => N_('Random-based'), + 'MAC-based' => N_('MAC-based'), }.freeze def self.random_based? diff --git a/config/initializers/foreman_register.rb b/config/initializers/foreman_register.rb index 7398397c969..829df319107 100644 --- a/config/initializers/foreman_register.rb +++ b/config/initializers/foreman_register.rb @@ -6,56 +6,56 @@ end Pagelets::Manager.with_key 'hosts/_list' do |ctx| - ctx.with_profile :general, _('General'), default: true do + ctx.with_profile :general, N_('General'), default: true do common_class = 'hidden-tablet hidden-xs ellipsis' - add_pagelet :hosts_table_column_header, key: :power_status, label: _('Power'), sortable: false, width: '80px', class: 'ca hidden-xs', + add_pagelet :hosts_table_column_header, key: :power_status, label: N_('Power'), sortable: false, width: '80px', class: 'ca hidden-xs', export_data: CsvExporter::ExportDefinition.new(:power_status, callback: ->(host) { PowerManager::PowerStatus.safe_power_state(host)[:state] }) add_pagelet :hosts_table_column_content, key: :power_status, class: 'ca hidden-xs', callback: ->(host) { react_component('PowerStatus', id: host.id, url: power_api_host_path(host)) } - add_pagelet :hosts_table_column_header, key: :name, label: _('Name'), sortable: true, width: '24%', locked: true + add_pagelet :hosts_table_column_header, key: :name, label: N_('Name'), sortable: true, width: '24%', locked: true add_pagelet :hosts_table_column_content, key: :name, callback: ->(host) { name_column(host) }, locked: true, class: 'ellipsis' - add_pagelet :hosts_table_column_header, key: :os_title, label: _('OS'), sortable: true, width: '17%', attr_callbacks: { title: ->(host) { _('Operating system') } }, export_key: 'operatingsystem', class: common_class + add_pagelet :hosts_table_column_header, key: :os_title, label: N_('OS'), sortable: true, width: '17%', attr_callbacks: { title: ->(host) { _('Operating system') } }, export_key: 'operatingsystem', class: common_class add_pagelet :hosts_table_column_content, key: :os_title, callback: ->(host) { (icon(host.operatingsystem, size: "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem }, class: common_class - add_pagelet :hosts_table_column_header, key: :owner, label: _('Owner'), sortable: true, width: '8%', class: common_class + add_pagelet :hosts_table_column_header, key: :owner, label: N_('Owner'), sortable: true, width: '8%', class: common_class add_pagelet :hosts_table_column_content, key: :owner, callback: ->(host) { host_owner_column(host) }, class: common_class - add_pagelet :hosts_table_column_header, key: :hostgroup, label: _('Host group'), sortable: true, width: '15%', class: common_class + add_pagelet :hosts_table_column_header, key: :hostgroup, label: N_('Host group'), sortable: true, width: '15%', class: common_class add_pagelet :hosts_table_column_content, key: :hostgroup, callback: ->(host) { label_with_link host.hostgroup, 23, @hostgroup_authorizer }, class: common_class - add_pagelet :hosts_table_column_header, key: :boot_time, label: _('Boot time'), sortable: true, width: '10%', export_key: 'reported_data.boot_time', class: common_class + add_pagelet :hosts_table_column_header, key: :boot_time, label: N_('Boot time'), sortable: true, width: '10%', export_key: 'reported_data.boot_time', class: common_class add_pagelet :hosts_table_column_content, key: :boot_time, callback: ->(host) { date_time_unless_empty(host.reported_data&.boot_time) }, class: common_class - add_pagelet :hosts_table_column_header, key: :last_report, label: _('Last report'), sortable: true, default_sort: 'DESC', width: '10%', class: common_class + add_pagelet :hosts_table_column_header, key: :last_report, label: N_('Last report'), sortable: true, default_sort: 'DESC', width: '10%', class: common_class add_pagelet :hosts_table_column_content, key: :last_report, callback: ->(host) { last_report_column(host) }, class: common_class - add_pagelet :hosts_table_column_header, key: :comment, label: _('Comment'), sortable: true, width: '7%', class: common_class + add_pagelet :hosts_table_column_header, key: :comment, label: N_('Comment'), sortable: true, width: '7%', class: common_class add_pagelet :hosts_table_column_content, key: :comment, class: common_class + ' ca', attr_callbacks: { title: ->(host) { h host.comment&.truncate(255) } }, callback: ->(host) { icon_text('comment', '') unless host.comment.empty? } end - ctx.with_profile :network_data, _('Network'), default: false do + ctx.with_profile :network_data, N_('Network'), default: false do common_class = 'hidden-tablet hidden-xs ellipsis' - add_pagelet :hosts_table_column_header, key: :ip, label: _('IPv4'), sortable: true, width: '10%', attr_callbacks: { title: ->(host) { _('IPv4 address') } }, priority: 200, class: common_class + add_pagelet :hosts_table_column_header, key: :ip, label: N_('IPv4'), sortable: true, width: '10%', attr_callbacks: { title: ->(host) { _('IPv4 address') } }, priority: 200, class: common_class add_pagelet :hosts_table_column_content, key: :ip, callback: ->(host) { host.ip }, priority: 200, class: common_class - add_pagelet :hosts_table_column_header, key: :ip6, label: _('IPv6'), sortable: true, width: '13%', attr_callbacks: { title: ->(host) { _('IPv6 address') } }, priority: 200, class: common_class + add_pagelet :hosts_table_column_header, key: :ip6, label: N_('IPv6'), sortable: true, width: '13%', attr_callbacks: { title: ->(host) { _('IPv6 address') } }, priority: 200, class: common_class add_pagelet :hosts_table_column_content, key: :ip6, callback: ->(host) { host.ip6 }, priority: 200, class: common_class - add_pagelet :hosts_table_column_header, key: :mac, label: _('MAC'), sortable: true, width: '10%', attr_callbacks: { title: ->(host) { _('MAC address') } }, priority: 200, class: common_class + add_pagelet :hosts_table_column_header, key: :mac, label: N_('MAC'), sortable: true, width: '10%', attr_callbacks: { title: ->(host) { _('MAC address') } }, priority: 200, class: common_class add_pagelet :hosts_table_column_content, key: :mac, callback: ->(host) { host.mac }, priority: 200, class: common_class end - ctx.with_profile :reported_data, _('Reported data'), default: false do + ctx.with_profile :reported_data, N_('Reported data'), default: false do common_class = 'hidden-tablet hidden-xs ellipsis' - add_pagelet :hosts_table_column_header, key: :model, label: _('Model'), sortable: true, width: '10%', export_key: 'compute_resource_or_model', class: common_class + add_pagelet :hosts_table_column_header, key: :model, label: N_('Model'), sortable: true, width: '10%', export_key: 'compute_resource_or_model', class: common_class add_pagelet :hosts_table_column_content, key: :model, callback: ->(host) { host.compute_resource_or_model }, class: common_class - add_pagelet :hosts_table_column_header, key: :sockets, label: _('Sockets'), width: '5%', export_key: 'reported_data.sockets', class: common_class + add_pagelet :hosts_table_column_header, key: :sockets, label: N_('Sockets'), width: '5%', export_key: 'reported_data.sockets', class: common_class add_pagelet :hosts_table_column_content, key: :sockets, callback: ->(host) { host.reported_data&.sockets }, class: common_class - add_pagelet :hosts_table_column_header, key: :cores, label: _('Cores'), width: '5%', export_key: 'reported_data.cores', class: common_class + add_pagelet :hosts_table_column_header, key: :cores, label: N_('Cores'), width: '5%', export_key: 'reported_data.cores', class: common_class add_pagelet :hosts_table_column_content, key: :cores, callback: ->(host) { host.reported_data&.cores }, class: common_class - add_pagelet :hosts_table_column_header, key: :ram, label: _('RAM'), width: '5%', export_key: 'reported_data.ram', class: common_class + add_pagelet :hosts_table_column_header, key: :ram, label: N_('RAM'), width: '5%', export_key: 'reported_data.ram', class: common_class add_pagelet :hosts_table_column_content, key: :ram, callback: ->(host) { humanize_bytes(host.reported_data&.ram, from: :mega) }, class: common_class - add_pagelet :hosts_table_column_header, key: :virtual, label: _('Virtual'), width: '5%', class: common_class + add_pagelet :hosts_table_column_header, key: :virtual, label: N_('Virtual'), width: '5%', class: common_class add_pagelet :hosts_table_column_content, key: :virtual, callback: ->(host) { virtual?(host) }, class: common_class - add_pagelet :hosts_table_column_header, key: :disks_total, label: _('Disks space'), width: '8%', attr_callbacks: { title: ->(host) { _('Disks total space') } }, export_key: 'reported_data.disks_total', class: common_class + add_pagelet :hosts_table_column_header, key: :disks_total, label: N_('Disks space'), width: '8%', attr_callbacks: { title: ->(host) { _('Disks total space') } }, export_key: 'reported_data.disks_total', class: common_class add_pagelet :hosts_table_column_content, key: :disks_total, callback: ->(host) { humanize_bytes(host.reported_data&.disks_total) }, class: common_class - add_pagelet :hosts_table_column_header, key: :kernel_version, label: _('Kernel version'), width: '12%', export_key: 'reported_data.kernel_version', class: common_class + add_pagelet :hosts_table_column_header, key: :kernel_version, label: N_('Kernel version'), width: '12%', export_key: 'reported_data.kernel_version', class: common_class add_pagelet :hosts_table_column_content, key: :kernel_version, callback: ->(host) { host.reported_data&.kernel_version }, class: common_class - add_pagelet :hosts_table_column_header, key: :bios_vendor, label: _('BIOS vendor'), width: '8%', export_key: 'reported_data.bios_vendor', class: common_class + add_pagelet :hosts_table_column_header, key: :bios_vendor, label: N_('BIOS vendor'), width: '8%', export_key: 'reported_data.bios_vendor', class: common_class add_pagelet :hosts_table_column_content, key: :bios_vendor, callback: ->(host) { host.reported_data&.bios_vendor }, class: common_class - add_pagelet :hosts_table_column_header, key: :bios_release_date, label: _('BIOS release date'), width: '10%', export_key: 'reported_data.bios_release_date', class: common_class + add_pagelet :hosts_table_column_header, key: :bios_release_date, label: N_('BIOS release date'), width: '10%', export_key: 'reported_data.bios_release_date', class: common_class add_pagelet :hosts_table_column_content, key: :bios_release_date, callback: ->(host) { host.reported_data&.bios_release_date }, class: common_class - add_pagelet :hosts_table_column_header, key: :bios_version, label: _('BIOS version'), width: '12%', export_key: 'reported_data.bios_version', class: common_class + add_pagelet :hosts_table_column_header, key: :bios_version, label: N_('BIOS version'), width: '12%', export_key: 'reported_data.bios_version', class: common_class add_pagelet :hosts_table_column_content, key: :bios_version, callback: ->(host) { host.reported_data&.bios_version }, class: common_class end end