Skip to content
Permalink
Browse files

Merge pull request #2500 from ekylibre/productnature-and-productnatur…

…e-variant-escaping-key-method

implemented behaviour for escaping key if it contains DOT in it's name
  • Loading branch information...
Aquaj committed Apr 10, 2019
2 parents ad54022 + 9724e9a commit 53a1f02bb80d07c0cf390a450cc4b0943ced2c09
Showing with 16 additions and 11 deletions.
  1. +4 −0 config/initializers/inflections.rb
  2. +3 −3 config/locales/fra/nomenclatures.yml
  3. +7 −1 lib/nomen/item.rb
  4. +2 −7 lib/nomen/nomenclature.rb
@@ -31,6 +31,10 @@
# Set pluralization active with the algorithms defined in [locale]/i18n.rb
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

def I18n.escape_key(key)
key.to_s.gsub('.', '-').to_sym
end

# set config for humanize
Humanize.configure do |config|
config.default_locale = :en # [:en, :fr], default: :en
@@ -3762,9 +3762,9 @@ fra:
lettuce_crop: "Culture de laitue"
lewis_hazelnut: "Noisette Lewis"
lifter: "Souleveur"
liquid_10_25_d1.4: "Azote binaire 10-25-0 densité 1.4"
liquid_10_34_d1.4: "Azote binaire 10-34-0 densité 1.4"
liquid_nitrogen_30_d1.3: "Azote liquide 30% densité 1.3"
liquid_10_25_d1-4: "Azote binaire 10-25-0 densité 1.4"
liquid_10_34_d1-4: "Azote binaire 10-34-0 densité 1.4"
liquid_nitrogen_30_d1-3: "Azote liquide 30% densité 1.3"
little_office_equipment: "Petit équipement de bureau"
little_office_good: "Consommable de bureau"
livestock_cleanliness_product: "Produit d’hygiène d’élevage"
@@ -178,7 +178,13 @@ def include?(other)

# Return human name of item
def human_name(options = {})
"nomenclatures.#{nomenclature.name}.items.#{name}".t(options.merge(default: ["items.#{name}".to_sym, "enumerize.#{nomenclature.name}.#{name}".to_sym, "labels.#{name}".to_sym, name.humanize]))
"nomenclatures.#{I18n.escape_key(nomenclature.name)}.items.#{I18n.escape_key(name)}"
.t(options.merge(default: [
"items.#{I18n.escape_key(name)}".to_sym,
"enumerize.#{I18n.escape_key(nomenclature.name)}.#{I18n.escape_key(name)}".to_sym,
"labels.#{I18n.escape_key(name)}".to_sym,
name.humanize
]))
end
alias humanize human_name
alias localize human_name
@@ -289,12 +289,7 @@ def table_name

# Returns hash with items in tree: {a => nil, b => {c => nil}}
def tree
x = @roots.collect(&:tree).join
return x
i.attributes.merge(parent: i.parent_name, name: i.name, left: i.left, right: i.right, depth: i.depth).deep_stringify_keys
return x
@roots.map do |_i|
end
@roots.collect(&:tree).join
end

def translateable?
@@ -303,7 +298,7 @@ def translateable?

# Return human name
def human_name(options = {})
"nomenclatures.#{name}.name".t(options.merge(default: ["labels.#{name}".to_sym, name.to_s.humanize]))
"nomenclatures.#{I18n.escape_key(name)}.name".t(options.merge(default: ["labels.#{I18n.escape_key(name)}".to_sym, name.to_s.humanize]))
end
alias humanize human_name

0 comments on commit 53a1f02

Please sign in to comment.
You can’t perform that action at this time.