i18n_scopes 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -30,7 +30,7 @@ Or install it yourself as:
30
30
  ### In your class (for example Controller)
31
31
 
32
32
  class Local::ExampleController < ActionController::Base
33
- i18n_default_scope :class_name, :translation, :action_name, :strip_controller_suffix => true, :plural_class => false
33
+ i18n_default_scope :class_name, :translation, :action_name, :strip_controller_suffix => true, :plural_classes => false
34
34
  i18n_scope :flash, :class_name, :action_name, :flashes
35
35
 
36
36
  def index
@@ -24,11 +24,11 @@ module I18nScopes
24
24
  # === Params:
25
25
  # * +path+: Either a single String or Symbol, or an Array of Symbols and Strings
26
26
  # * +options+: options to be used within this class, they will overwrite the configuration made in Configuration
27
- # * :plural_class: if the class name should be pluralized or singularized
27
+ # * :plural_classes: if the class name should be pluralized or singularized
28
28
  # * :strip_controller_suffix: if the _controller suffix of classes should be stripped or not
29
29
  #
30
30
  # == Usage:
31
- # i18n_scope :flash, :modules, :class_name, :action_name, :custom_value, "static_prefix", :plural_class => true, :strip_controller_suffix => true
31
+ # i18n_scope :flash, :modules, :class_name, :action_name, :custom_value, "static_prefix", :plural_classes => true, :strip_controller_suffix => true
32
32
  #
33
33
  # this will create a +t_flash+ method
34
34
  #
@@ -29,6 +29,7 @@ module I18nScopes
29
29
  respondables = [object]
30
30
  respondables += [*options.delete(:respondable)] if options.include?(:respondable)
31
31
  respondables << I18nScopes::TranslationUtils # add utils at last
32
+ parameter_matchings[:options] = self.options.merge(parameter_matchings[:options]) # merge options
32
33
  custom_path.each do |path_name|
33
34
  if path_name.is_a?(Symbol)
34
35
  # find a respondable which responds_to path_name
@@ -22,7 +22,6 @@ module I18nScopes
22
22
  {}
23
23
  end
24
24
  additional_parameters.merge!(options.delete(:parameter_matchings)) if options.include?(:parameter_matchings)
25
-
26
25
  parameter_matchings = {
27
26
  klass: self.class,
28
27
  object: self,
@@ -2,8 +2,6 @@ module I18nScopes
2
2
 
3
3
  module TranslationUtils
4
4
 
5
- CONTROLLER_SUFFIX = "_controller"
6
-
7
5
  # this method will return all modules in a array, each module will be underscored
8
6
  #
9
7
  # === Params:
@@ -16,20 +14,19 @@ module I18nScopes
16
14
 
17
15
  # this method will return a underscored class_name
18
16
  #
19
- # Note: plural_class and strip_controller_suffix will be used here
17
+ # Note: plural_classes and strip_controller_suffix will be used here
20
18
  #
21
19
  # === Params:
22
20
  # * +klass+: the class on which the name should be get
23
- # * +options+: options like plural_class and strip_controller_suffix
21
+ # * +options+: options like plural_classes and strip_controller_suffix
24
22
  def self.class_name(klass, options = {})
25
- class_name_options = options.merge(options)
26
- class_name = if class_name_options[:strip_controller_suffix] && klass.respond_to?(:controller_name)
23
+ class_name = if options[:strip_controller_suffix] && klass.respond_to?(:controller_name)
27
24
  klass.controller_name
28
25
  else
29
26
  demodulized = ActiveSupport::Inflector.demodulize(klass.name)
30
27
  ActiveSupport::Inflector.underscore(demodulized)
31
28
  end
32
- if class_name_options[:plural_class]
29
+ if options[:plural_classes]
33
30
  ActiveSupport::Inflector.pluralize(class_name)
34
31
  else
35
32
  ActiveSupport::Inflector.singularize(class_name)
@@ -1,3 +1,3 @@
1
1
  module I18nScopes
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -18,7 +18,7 @@ class ScopeTWithPath
18
18
  end
19
19
 
20
20
  def translate_with_respondable
21
- t_scoped(:name, :path_extension => [:type], :respondable => Respondable.new)
21
+ t_scoped(:name, :path_extension => [:type], respondable: Respondable.new)
22
22
  end
23
23
 
24
24
  def translate_flash
@@ -0,0 +1,15 @@
1
+ class TranslateWithoutControllerSuffix
2
+
3
+ include I18nScopes::Scope
4
+
5
+ i18n_scope :controller_name, :class_name, strip_controller_suffix: true, plural_classes: false
6
+
7
+ def translate
8
+ t_controller_name(:name)
9
+ end
10
+
11
+ def self.controller_name
12
+ "scopes"
13
+ end
14
+
15
+ end
data/spec/locales/en.yml CHANGED
@@ -23,4 +23,6 @@ en:
23
23
  message: ScopeTWithPathFromScope
24
24
  inheritance_overwritten:
25
25
  flashes:
26
- message: InheritedScopeOverwritten
26
+ message: InheritedScopeOverwritten
27
+ scopes:
28
+ name: ScopeTWithPathAndControllerName
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ require 'example_classes/translate_without_controller_suffix'
3
+
4
+ describe TranslateWithoutControllerSuffix do
5
+
6
+
7
+ its(:translate) { should == "ScopeTWithPathAndControllerName"}
8
+
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2012-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -57,6 +57,7 @@ files:
57
57
  - spec/example_classes/scope_t_with_path_in_module.rb
58
58
  - spec/example_classes/should_define_scope.rb
59
59
  - spec/example_classes/should_have_attached_scoped_t.rb
60
+ - spec/example_classes/translate_without_controller_suffix.rb
60
61
  - spec/include_scope_spec.rb
61
62
  - spec/inherit_from_parent_spec.rb
62
63
  - spec/inherited_spec.rb
@@ -64,6 +65,7 @@ files:
64
65
  - spec/scope_spec.rb
65
66
  - spec/should_define_scope_in_module_spec.rb
66
67
  - spec/should_define_scope_spec.rb
68
+ - spec/should_translate_without_controller_name_spec.rb
67
69
  - spec/spec_helper.rb
68
70
  homepage: http://github.com/menostos/i18n_scopes
69
71
  licenses: []
@@ -99,6 +101,7 @@ test_files:
99
101
  - spec/example_classes/scope_t_with_path_in_module.rb
100
102
  - spec/example_classes/should_define_scope.rb
101
103
  - spec/example_classes/should_have_attached_scoped_t.rb
104
+ - spec/example_classes/translate_without_controller_suffix.rb
102
105
  - spec/include_scope_spec.rb
103
106
  - spec/inherit_from_parent_spec.rb
104
107
  - spec/inherited_spec.rb
@@ -106,4 +109,5 @@ test_files:
106
109
  - spec/scope_spec.rb
107
110
  - spec/should_define_scope_in_module_spec.rb
108
111
  - spec/should_define_scope_spec.rb
112
+ - spec/should_translate_without_controller_name_spec.rb
109
113
  - spec/spec_helper.rb