i18n_utils 0.0.3 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0c593da61105c71a8675a0f610b1a2e1962d7c3f
4
- data.tar.gz: 235e5cc384d46ff61113ec660a982b45c677177e
2
+ SHA256:
3
+ metadata.gz: f6c4c68b75a04d2b3e42d6f6fb4604aa1e632976461d879fea418ccbc7c7cf6c
4
+ data.tar.gz: db0fa72e45a481200df95d1b516e79686c9ea50007424d1d5430bcd69809b100
5
5
  SHA512:
6
- metadata.gz: 1330a30df11b48d8b93f848ef389e65ef1354f562fe30a27d496929ad5cd9ebf49c37ae4aa70f9de6be98165b3f5019f224448ad66f0dcc94d71a49cb2d2fe3c
7
- data.tar.gz: b5d3363f3c3d6bde770ab1173fafaba7693b3fbb513ea62585d5b90fadb2fc7e47f0926f1ac3fb347c87acd79759fa6c6653e6a8a6e42e7ed7e305a3d79eda01
6
+ metadata.gz: 4b7d6a11e594c35cda847bf8a33b44a985fc2b1122b5a6a9a139a2f1bff2369bc46bc7cc8657bdade4c7efca00a6becb67ba828d6a9c3f9e027e46656b7e6b32
7
+ data.tar.gz: aa59423d65380350f6d9c35e5de1727edc8b1189c78029e5054b38529e6c7cbfcadc5ec6f9ba9bf0c7bd2974236067049095f3160573dc49d0f264b4bea8a51f
data/README.md CHANGED
@@ -16,7 +16,7 @@ Get this part with `include I18nUtils::Model` in e.g. your `ApplicationHelper`.
16
16
 
17
17
  I think the Rails way to translate attributes and models is ugly and on the wrong object.
18
18
 
19
- With this, your views can do `t_model(User)` instead of `User.model_name.human`.
19
+ With this, your views can do `t_model(User)` instead of `User.model_name.human`. Or pass an instance: `t_model(some_user)`
20
20
 
21
21
  Also `t_attribute(User, :email)` instead of `User.human_attribute_name(:email)`.
22
22
 
@@ -32,16 +32,16 @@ Get this part with `include I18nUtils::Scope` in e.g. your `ApplicationHelper`.
32
32
  Links or other markup in the middle of a translation is tricky. Either you put the HTML straight in the translation and risk the translator messing it up, or it becomes a mess:
33
33
 
34
34
  ``` slim
35
- = t(:"welcome.sign_in_now.text",
36
- sign_in: link_to(t(:"welcome.sign_in_now.sign_in"), sign_in_url))
35
+ = t("welcome.sign_in_now.text",
36
+ sign_in: link_to(t("welcome.sign_in_now.sign_in"), sign_in_url))
37
37
  ```
38
38
 
39
39
  The `t_scope` helper lets you use blocks for interpolated values, in your regular template:
40
40
 
41
41
  ``` slim
42
- = t_scope(:"welcome.sign_in_now.text") do |scope|
43
- scope.sign_in do
44
- = link_to(scope.t(:sign_in), sign_in_url))
42
+ = t_scope("welcome.sign_in_now.text") do |scope|
43
+ - scope.sign_in do
44
+ = link_to(scope.t(:sign_in), sign_in_url)
45
45
  ```
46
46
 
47
47
 
@@ -1,3 +1,3 @@
1
1
  module I18nUtils
2
- VERSION = "0.0.3"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/i18n_utils.rb CHANGED
@@ -9,7 +9,8 @@ module I18nUtils
9
9
  klass.human_attribute_name(attribute)
10
10
  end
11
11
 
12
- def t_model(klass)
12
+ def t_model(class_or_instance)
13
+ klass = class_or_instance.respond_to?(:model_name) ? class_or_instance : class_or_instance.class
13
14
  klass.model_name.human
14
15
  end
15
16
  end
data/spec/helpers_spec.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "i18n_utils"
2
2
 
3
+ class FakeModel; end
4
+
3
5
  describe I18nUtils do
4
6
  include I18nUtils::Helper
5
7
 
@@ -13,11 +15,22 @@ describe I18nUtils do
13
15
  end
14
16
 
15
17
  describe "t_model" do
16
- it "uses model_name.human" do
17
- klass = double
18
- klass.stub_chain(:model_name, :human).and_return("Clase")
19
- t_model(klass).should == "Clase"
20
- I18nUtils.t_model(klass).should == "Clase"
18
+ before do
19
+ FakeModel.stub_chain(:model_name, :human).and_return("Clase")
20
+ end
21
+
22
+ context "given a class" do
23
+ it "uses model_name.human" do
24
+ t_model(FakeModel).should == "Clase"
25
+ I18nUtils.t_model(FakeModel).should == "Clase"
26
+ end
27
+ end
28
+
29
+ context "given an instance" do
30
+ it "looks it up on the class" do
31
+ t_model(FakeModel.new).should == "Clase"
32
+ I18nUtils.t_model(FakeModel.new).should == "Clase"
33
+ end
21
34
  end
22
35
  end
23
36
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: active_support
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description:
@@ -87,39 +87,34 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - Gemfile
92
90
  - LICENSE.txt
93
91
  - README.md
94
- - Rakefile
95
- - i18n_utils.gemspec
96
92
  - lib/i18n_utils.rb
97
93
  - lib/i18n_utils/version.rb
98
94
  - spec/helpers_spec.rb
99
- homepage: http://github.com/henrik/i18n_utils
95
+ homepage: https://github.com/henrik/i18n_utils
100
96
  licenses:
101
97
  - MIT
102
- metadata: {}
98
+ metadata:
99
+ rubygems_mfa_required: 'true'
103
100
  post_install_message:
104
101
  rdoc_options: []
105
102
  require_paths:
106
103
  - lib
107
104
  required_ruby_version: !ruby/object:Gem::Requirement
108
105
  requirements:
109
- - - ! '>='
106
+ - - ">="
110
107
  - !ruby/object:Gem::Version
111
108
  version: '0'
112
109
  required_rubygems_version: !ruby/object:Gem::Requirement
113
110
  requirements:
114
- - - ! '>='
111
+ - - ">="
115
112
  - !ruby/object:Gem::Version
116
113
  version: '0'
117
114
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.0.3
115
+ rubygems_version: 3.2.31
120
116
  signing_key:
121
117
  specification_version: 4
122
118
  summary: I18n utilities for Ruby on Rails.
123
119
  test_files:
124
120
  - spec/helpers_spec.rb
125
- has_rdoc:
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in i18n_utils.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/i18n_utils.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'i18n_utils/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "i18n_utils"
8
- spec.version = I18nUtils::VERSION
9
- spec.authors = ["Henrik Nyh"]
10
- spec.email = ["henrik@nyh.se"]
11
- spec.summary = "I18n utilities for Ruby on Rails."
12
- spec.homepage = "http://github.com/henrik/i18n_utils"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files`.split($/)
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_dependency "i18n"
21
- spec.add_dependency "active_support"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
26
- end