tolk 1.5.2 → 1.6.0.alpha1

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
2
  SHA1:
3
- metadata.gz: 1c19b0b57cefe554cc66f643db8c50687d893f7b
4
- data.tar.gz: ab0b34b9f6b9916bc4704c95c6ef287ff033deb1
3
+ metadata.gz: ca7dad7fa94ddec0e5d929c9cf06e95af7b2ee6b
4
+ data.tar.gz: 489d41d64a6a62a3699947467467fc20dce346e8
5
5
  SHA512:
6
- metadata.gz: 5e86f97bb6601c3b8decb7569b194b9708ee0690c0d68b66e844ed863d59de1b85276542aa1619c8c3d5edd9f7c711e8bc0e357f12de35a290f1f3886265c770
7
- data.tar.gz: fe545ba06f6ff8d2d53c5462417bb6a38037a40c1bf6c00a4dd1be19181b065788be4d873d23489e90fe64307219d82d3ac9ffc9e2e331a30652c2381160b696
6
+ metadata.gz: 9a3be6fb7c98e14dccdb1f5bf9e32c8d956ec528f237626419641cb925012cecd8c622e7d58d3375b4e497d5129ca33c684c376e6fc80987d0f7855f23ead1e2
7
+ data.tar.gz: 55fa32b0234ec09206e0ce054a6c151bfae8cb17ab22f48edda0360770e268320fa0b2d3201870c2e06349e69abc5a3eb0f2350859e8903492f650314b5666d2
@@ -76,9 +76,13 @@ module Tolk
76
76
  params.require(:tolk_locale).permit(:name)
77
77
  end
78
78
 
79
+ # TODO: whitelist incoming translation params
80
+ # translation permitted params: :phrase_id, :locale_id, :text, :primary_updated, :previous_text, :locale, :phrase
81
+ # test params: "translations"=>[{"id"=>"", "phrase_id"=>"8", "locale_id"=>"5", "text"=>"Dead men don't bite"}, {"id"=>"", "phrase_id"=>"7", "locale_id"=>"5", "text"=>""}]
79
82
  def translation_params
80
- params.permit(translations: [:id, :phrase_id, :locale_id, :text])[:translations]
83
+ params.require(:translations)
81
84
  end
82
85
 
86
+
83
87
  end
84
88
  end
@@ -38,7 +38,7 @@ module Tolk
38
38
  @_primary_locale = nil if reload
39
39
  @_primary_locale ||= begin
40
40
  raise "Primary locale is not set. Please set Locale.primary_locale_name in your application's config file" unless self.primary_locale_name
41
- where(name: self.primary_locale_name).first_or_create
41
+ find_or_create_by(name: self.primary_locale_name)
42
42
  end
43
43
  end
44
44
 
@@ -55,7 +55,7 @@ module Tolk
55
55
  end
56
56
 
57
57
  def dump_yaml(name, *args)
58
- where(name: name).first.dump(*args)
58
+ find_by_name(name).dump(*args)
59
59
  end
60
60
 
61
61
  def special_key_or_prefix?(prefix, key)
@@ -75,7 +75,7 @@ module Tolk
75
75
  end
76
76
 
77
77
  def has_updated_translations?
78
- translations.where('tolk_translations.primary_updated' => true).count > 0
78
+ translations.count(:conditions => {:'tolk_translations.primary_updated' => true}) > 0
79
79
  end
80
80
 
81
81
  def phrases_with_translation(page = nil)
@@ -102,7 +102,6 @@ module Tolk
102
102
  phrases = phrases.where('tolk_phrases.id NOT IN (?)', existing_ids) if existing_ids.present?
103
103
 
104
104
  result = phrases.paginate({:page => page, :per_page => Phrase.per_page}.merge(options))
105
- ActiveRecord::Associations::Preloader.new result, :translations
106
105
  result
107
106
  end
108
107
 
@@ -133,7 +132,6 @@ module Tolk
133
132
  # phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?) AND tolk_phrases.id IN(?)', existing_ids, found_translations_ids]) if existing_ids.present?
134
133
  phrases = phrases.where(['tolk_phrases.id NOT IN (?) AND tolk_phrases.id IN(?)', existing_ids, found_translations_ids]) if existing_ids.present?
135
134
  result = phrases.paginate({:page => page}.merge(options))
136
- ActiveRecord::Associations::Preloader.new result, :translations
137
135
  result
138
136
  end
139
137
 
@@ -162,7 +160,7 @@ module Tolk
162
160
  end
163
161
 
164
162
  def get(key)
165
- if phrase = Tolk::Phrase.where(key: key).first
163
+ if phrase = Tolk::Phrase.find_by_key(key)
166
164
  t = self.translations.where(:phrase_id => phrase.id).first
167
165
  t.text if t
168
166
  end
@@ -171,7 +169,6 @@ module Tolk
171
169
  def translations_with_html
172
170
  translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
173
171
  tolk_translations.text LIKE '%<%' AND tolk_phrases.key NOT LIKE '%_html'", :joins => :phrase)
174
- ActiveRecord::Associations::Preloader.new translations, :phrase
175
172
  translations
176
173
  end
177
174
 
@@ -179,7 +176,7 @@ module Tolk
179
176
  if old_name.blank? || new_name.blank?
180
177
  "You need to provide both names, aborting."
181
178
  else
182
- if locale = where(name: old_name).first
179
+ if locale = find_by_name(old_name)
183
180
  locale.name = new_name
184
181
  locale.save
185
182
  "Locale ' #{old_name}' was renamed '#{new_name}'"
@@ -211,7 +208,6 @@ module Tolk
211
208
  phrase.translation = phrase.translations.for(self)
212
209
  end
213
210
 
214
- ActiveRecord::Associations::Preloader.new result, :translations
215
211
 
216
212
  result
217
213
  end
@@ -19,7 +19,7 @@
19
19
  </tr>
20
20
  <% @phrases.each do |phrase| %>
21
21
 
22
- <% if translation = phrase.translations.where(locale_id: @locale.id).first || Tolk::Translation.new(:locale => @locale, :phrase => phrase) %>
22
+ <% if translation = phrase.translations.find_by_locale_id(@locale.id) || Tolk::Translation.new(:locale => @locale, :phrase => phrase) %>
23
23
  <tr>
24
24
  <td class="translation">
25
25
  <%= hidden_field_tag :"translations[][id]", translation.id, :id => "#{translation.object_id}_id" %>
@@ -40,7 +40,7 @@
40
40
  <%= format_i18n_value(phrase.translations.primary.text) -%>
41
41
  <% end -%>
42
42
  <%= boolean_warning if phrase.translations.primary.boolean? -%>
43
-
43
+
44
44
  <span class="key" title="<%= phrase.key %>"><%= params[:k].present? ?
45
45
  highlight(h(truncate(phrase.key, :length => 100)), params[:k]) :
46
46
  h(truncate(phrase.key, :length => 100)) %></span>
data/lib/tolk/engine.rb CHANGED
@@ -7,8 +7,10 @@ module Tolk
7
7
 
8
8
  isolate_namespace Tolk
9
9
 
10
- initializer :assets do |app|
11
- app.config.assets.precompile += ['tolk/libraries.js']
10
+ if Rails.version >= '3.1'
11
+ initializer :assets do |app|
12
+ app.config.assets.precompile += ['tolk/libraries.js']
13
+ end
12
14
  end
13
15
  end
14
16
  end
data/lib/tolk/import.rb CHANGED
@@ -20,7 +20,7 @@ module Tolk
20
20
  end
21
21
 
22
22
  def import_locale(locale_name)
23
- locale = Tolk::Locale.where(name: locale_name).first_or_create
23
+ locale = Tolk::Locale.find_or_create_by_name(locale_name)
24
24
  data = locale.read_locale_file
25
25
  return unless data
26
26
 
data/lib/tolk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tolk
2
- VERSION = "1.5.2"
2
+ VERSION = "1.6.0.alpha1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tolk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -12,22 +12,8 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-09-16 00:00:00.000000000 Z
15
+ date: 2014-05-28 00:00:00.000000000 Z
16
16
  dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: rails
19
- requirement: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - "~>"
22
- - !ruby/object:Gem::Version
23
- version: 4.0.0
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: 4.0.0
31
17
  - !ruby/object:Gem::Dependency
32
18
  name: will_paginate
33
19
  requirement: !ruby/object:Gem::Requirement
@@ -48,98 +34,14 @@ dependencies:
48
34
  requirements:
49
35
  - - ">="
50
36
  - !ruby/object:Gem::Version
51
- version: 0.8.6
37
+ version: '0.8'
52
38
  type: :runtime
53
39
  prerelease: false
54
40
  version_requirements: !ruby/object:Gem::Requirement
55
41
  requirements:
56
42
  - - ">="
57
43
  - !ruby/object:Gem::Version
58
- version: 0.8.6
59
- - !ruby/object:Gem::Dependency
60
- name: capybara
61
- requirement: !ruby/object:Gem::Requirement
62
- requirements:
63
- - - '='
64
- - !ruby/object:Gem::Version
65
- version: 2.2.1
66
- type: :development
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - '='
71
- - !ruby/object:Gem::Version
72
- version: 2.2.1
73
- - !ruby/object:Gem::Dependency
74
- name: factory_girl_rails
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
- - !ruby/object:Gem::Dependency
88
- name: sqlite3
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: '0'
101
- - !ruby/object:Gem::Dependency
102
- name: mocha
103
- requirement: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- version: '0'
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- - !ruby/object:Gem::Dependency
116
- name: launchy
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
- - !ruby/object:Gem::Dependency
130
- name: selenium-webdriver
131
- requirement: !ruby/object:Gem::Requirement
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
- type: :development
137
- prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: '0'
44
+ version: '0.8'
143
45
  description: Tolk is a web interface for doing i18n translations packaged as an engine
144
46
  for Rails applications.
145
47
  email: david@loudthinking.com
@@ -197,12 +99,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
99
  requirements:
198
100
  - - ">="
199
101
  - !ruby/object:Gem::Version
200
- version: 1.9.3
102
+ version: '0'
201
103
  required_rubygems_version: !ruby/object:Gem::Requirement
202
104
  requirements:
203
- - - ">="
105
+ - - ">"
204
106
  - !ruby/object:Gem::Version
205
- version: '0'
107
+ version: 1.3.1
206
108
  requirements: []
207
109
  rubyforge_project:
208
110
  rubygems_version: 2.2.2