air18n 0.1.42 → 0.1.43
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/lib/air18n.rb +1 -1
- data/lib/air18n/backend.rb +4 -3
- data/lib/air18n/phrase_screenshot.rb +18 -1
- data/lib/air18n/version.rb +1 -1
- metadata +2 -2
data/lib/air18n.rb
CHANGED
@@ -10,7 +10,7 @@ require 'air18n/default_text_change_observer'
|
|
10
10
|
require 'air18n/reflection'
|
11
11
|
|
12
12
|
module Air18n
|
13
|
-
AIR18N_RESERVED_KEYS = [:routes_context, :suppress_ct, :default_is_low_priority, :disable_xss_check, :disable_bookkeeping]
|
13
|
+
AIR18N_RESERVED_KEYS = [:routes_context, :suppress_ct, :default_is_low_priority, :disable_xss_check, :disable_bookkeeping, :context]
|
14
14
|
|
15
15
|
RTL_LOCALES = [ :he, :ar ]
|
16
16
|
|
data/lib/air18n/backend.rb
CHANGED
@@ -146,11 +146,12 @@ module Air18n
|
|
146
146
|
@prim_and_proper.guess(text, orig_locale, other_locale)
|
147
147
|
end
|
148
148
|
|
149
|
-
# We will only take
|
149
|
+
# We will only take 2 screenshots per Rails instance per key.
|
150
150
|
# This is to avoid having to moderate 200 screenshots for every new site-wide
|
151
151
|
# phrase.
|
152
|
-
# Because this is a per-Rails-thread cap,
|
153
|
-
|
152
|
+
# Because this is a per-Rails-thread cap, it is a lower bound for how many
|
153
|
+
# screenshot we will end up with per widely-used phrase.
|
154
|
+
APPROX_MAX_SCREENSHOTS_PER_KEY = 3
|
154
155
|
|
155
156
|
# This method does the meat of Air18n functionality.
|
156
157
|
# 1) Finds the translations for specified key and locale, falling back to
|
@@ -13,7 +13,7 @@ module Air18n
|
|
13
13
|
def self.all_phrase_urls
|
14
14
|
Hash.new { |h, k| h[k] = [] }.tap do |all_phrase_urls|
|
15
15
|
# Uses raw SQL for speed.
|
16
|
-
connection.select_all("SELECT `phrase_key`, `action`, `controller` FROM phrase_screenshots").each do |record|
|
16
|
+
connection.select_all("SELECT `phrase_key`, `action`, `controller` FROM phrase_screenshots where screenshot_url != ''").each do |record|
|
17
17
|
all_phrase_urls[record['phrase_key']] << make_routes_context(record['controller'], record['action'])
|
18
18
|
end
|
19
19
|
end
|
@@ -72,5 +72,22 @@ module Air18n
|
|
72
72
|
controller, action = page_id.split("#")
|
73
73
|
Struct.new(:controller, :action).new(controller, action)
|
74
74
|
end
|
75
|
+
|
76
|
+
# Associates a phrase with a controller, action pair and a screenshot.
|
77
|
+
# Set screenshot_url to the empty string if you don't have a screenshot.
|
78
|
+
# Returns the PhraseScreenshot.
|
79
|
+
def self.associate_phrase_with_screenshot(
|
80
|
+
phrase_key, controller_name, action_name, screenshot_url)
|
81
|
+
ps = PhraseScreenshot.find_or_create_by_controller_and_action_and_phrase_key(
|
82
|
+
controller_name, action_name, phrase_key, :screenshot_url => screenshot_url)
|
83
|
+
|
84
|
+
# If the PhraseScreenshot already existed, update the screenshot URL.
|
85
|
+
if ps.screenshot_url.blank? && ps.screenshot_url != screenshot_url
|
86
|
+
ps.screenshot_url = screenshot_url
|
87
|
+
ps.save
|
88
|
+
end
|
89
|
+
|
90
|
+
ps
|
91
|
+
end
|
75
92
|
end
|
76
93
|
end
|
data/lib/air18n/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: air18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.43
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-12-
|
16
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: i18n
|