bullet_train 1.0.30 → 1.0.31

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
  SHA256:
3
- metadata.gz: 4daae6a44c0ee84d06666767d1ca5b73655b3ed98aa0b9efcffb019c5691edf7
4
- data.tar.gz: 0ca25849d1a29c888d6687ca4fbcb11a31db8ba8cc23ed96a6aaf61e484fe4b1
3
+ metadata.gz: 2967f0b80a95786b9a7e0816284db63ed4b149a644b1c050df1904a56df7947f
4
+ data.tar.gz: 92ac669e6fb6091e32772a8281207b35bb034a4481649971c4682e74486734dd
5
5
  SHA512:
6
- metadata.gz: 9cc32562c77ed0a146aab0a8fdc3b1e2e3e45911d94c5bfc31cd0a259f17ca9de44481e025b0f7de6fceb2a5286db47e86179d17e859d1bedd06b9104955d538
7
- data.tar.gz: f155cfc57b9f831c68c1e984272fe815784ab2ae1bee3713bb0ff68ab3e480c235adb30d603c2056b097c24789567c9e250c7aaab8eebd18da01a90006eaac95
6
+ metadata.gz: 63ade82241aab3d3ca9267e8217ef604bde7f1142b25e63b21d1a95c93b0fa914ec51ee0f869c9b1080500e5b15a79317eefe369c91edd8db81dedf01bd37d46
7
+ data.tar.gz: c241470aa225ea03179125b2ac640ef34a8958058e2ae5457d3b1ca37de560d05808b15568b6bee2755e5fb6a44ef9b3fcc135b7160e5c77a797e6ccea76c07d
@@ -35,11 +35,43 @@ module Account::LocaleHelper
35
35
  end
36
36
 
37
37
  def t(key, options = {})
38
+ # When bundled Ruby gems provide a lot of translations, it can be difficult to figure out which strings in the
39
+ # application are coming from where. To help with this, you can add `?debug=true` to any URL and we'll output
40
+ # any rendered strings and their translation keys on the console.
41
+ unless Rails.env.production?
42
+ if params[:log_locales] || params[:show_locales]
43
+ # Often times we're only receiving partial keys like `.section`, so this is a crazy hack to trick I18n.t into
44
+ # telling us what the full key ended up being.
45
+ begin
46
+ super(key + "💣", options.except(:default))
47
+ rescue I18n::MissingTranslationData => exception
48
+ full_key = exception.message.rpartition(" ").last.gsub("💣", "")
49
+ end
50
+ end
51
+ end
52
+
38
53
  if account_controller?
39
- # give preference to the options they've passed in.
54
+ # Give preference to the options they've passed in.
40
55
  options = models_locales(@child_object, @parent_object).merge(options)
41
56
  end
42
- super(key, options)
57
+
58
+ result = super(key, options)
59
+
60
+ unless Rails.env.production?
61
+ if params[:log_locales]
62
+ if result == options[:default]
63
+ puts "🌐 #{full_key}: Not found? Result matched default: \"#{result}\"".yellow
64
+ else
65
+ puts "🌐 #{full_key}: \"#{result}\"".green
66
+ end
67
+ end
68
+
69
+ if params[:show_locales]
70
+ return full_key
71
+ end
72
+ end
73
+
74
+ return result
43
75
  end
44
76
 
45
77
  # like 't', but if the key isn't found, it returns nil.
@@ -2,6 +2,8 @@ require 'io/wait'
2
2
 
3
3
  module BulletTrain
4
4
  class Resolver
5
+ include I18n::Backend::Flatten
6
+
5
7
  def initialize(needle)
6
8
  @needle = needle
7
9
  end
@@ -89,7 +91,7 @@ module BulletTrain
89
91
  package_name: nil,
90
92
  }
91
93
 
92
- result[:absolute_path] = class_path || partial_path || file_path
94
+ result[:absolute_path] = class_path || partial_path || locale_path || file_path
93
95
 
94
96
  if result[:absolute_path]
95
97
  base_path = "bullet_train" + result[:absolute_path].split("/bullet_train").last
@@ -144,5 +146,22 @@ module BulletTrain
144
146
  # We don't have to do anything here... the absolute path is what we're passed, and we just pass it back.
145
147
  @needle
146
148
  end
149
+
150
+ def locale_path
151
+ # This is a complete list of translation files provided by this app or any linked Bullet Train packages.
152
+ (["#{Rails.root.to_s}/config/locales"] + `find ./tmp/gems/*`.lines.map(&:strip).map { |link| File.readlink(link) + "/config/locales" }).each do |locale_source|
153
+ if File.exist?(locale_source)
154
+ `find -L #{locale_source} | grep ".yml"`.lines.map(&:strip).each do |file_path|
155
+ yaml = YAML.load_file(file_path, aliases: true)
156
+ translations = flatten_translations(nil, yaml, nil, false)
157
+ if translations[@needle.to_sym].present?
158
+ return file_path
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ return nil
165
+ end
147
166
  end
148
167
  end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.0.30"
2
+ VERSION = "1.0.31"
3
3
  end
@@ -21,7 +21,7 @@ namespace :bullet_train do
21
21
  target = `bundle show #{linked_gem}`.chomp
22
22
  if target.present?
23
23
  puts "Linking '#{linked_gem}' to '#{target}'."
24
- puts `ln -s #{target} tmp/gems/#{linked_gem}`
24
+ `ln -s #{target} tmp/gems/#{linked_gem}`
25
25
  end
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.30
4
+ version: 1.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver