phraseapp-in-context-editor-ruby 1.4.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +7 -11
- data/.gitignore +0 -1
- data/.tool-versions +1 -1
- data/CODEOWNERS +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +241 -0
- data/Guardfile +13 -13
- data/README.md +81 -51
- data/RELEASING.md +10 -0
- data/lib/generators/phraseapp_in_context_editor/install_generator.rb +3 -9
- data/lib/generators/phraseapp_in_context_editor/templates/phraseapp_in_context_editor.rb +9 -17
- data/lib/phraseapp-in-context-editor-ruby/adapters/fast_gettext.rb +20 -20
- data/lib/phraseapp-in-context-editor-ruby/adapters/i18n.rb +10 -10
- data/lib/phraseapp-in-context-editor-ruby/backend_service.rb +12 -99
- data/lib/phraseapp-in-context-editor-ruby/config.rb +13 -50
- data/lib/phraseapp-in-context-editor-ruby/delegate/fast_gettext.rb +13 -15
- data/lib/phraseapp-in-context-editor-ruby/delegate/i18n_delegate.rb +4 -50
- data/lib/phraseapp-in-context-editor-ruby/delegate.rb +13 -14
- data/lib/phraseapp-in-context-editor-ruby/engine.rb +5 -6
- data/lib/phraseapp-in-context-editor-ruby/view_helpers.rb +25 -19
- data/lib/phraseapp-in-context-editor-ruby.rb +15 -54
- data/phraseapp-in-context-editor-ruby.gemspec +18 -33
- metadata +27 -101
- data/lib/generators/phraseapp_in_context_editor/templates/README +0 -10
- data/lib/phraseapp-in-context-editor-ruby/api_collection.rb +0 -41
- data/lib/phraseapp-in-context-editor-ruby/api_wrapper.rb +0 -59
- data/lib/phraseapp-in-context-editor-ruby/cache.rb +0 -37
- data/lib/phraseapp-in-context-editor-ruby/displayable_key_identifier.rb +0 -46
- data/lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb +0 -44
- data/lib/phraseapp-in-context-editor-ruby/hash_flattener.rb +0 -53
- data/lib/phraseapp-in-context-editor-ruby/key_names_cache.rb +0 -53
- data/lib/phraseapp-in-context-editor-ruby/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b7a566334e03f1cbe18e29077141679ee3d3df137e5560ca0139fd45478671
|
4
|
+
data.tar.gz: 46c88c54d886a7f43a46bc818665aa20468c85f64ddd3f1798ecf8f4f2dbeb5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22afc92bedfa12c38fa5dbdaf1f7772ff1931d9492eaecd8683dca3b09cb9a0f983bdc118c57576d2e8ae3fb3542b278cbfe5eccfbad16c073df2f131e1bfbb2
|
7
|
+
data.tar.gz: '017598d5cc05bd514b6e052a1856ce928705c65f77b48c31c4fe5cc6ab9954c1b0d7edb4c69d2534be1736aad5816b6db82299b3a1728bdf4480d21bb38b663d'
|
data/.github/workflows/test.yml
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
name: Test
|
2
|
-
on: [push]
|
2
|
+
on: [ push ]
|
3
3
|
jobs:
|
4
4
|
test:
|
5
|
-
strategy:
|
6
|
-
fail-fast: false
|
7
|
-
matrix:
|
8
|
-
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
|
9
5
|
runs-on: ubuntu-latest
|
10
6
|
steps:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
- uses: actions/checkout@v2
|
8
|
+
- uses: ruby/setup-ruby@319066216501fbd5e2d568f14b7d68c19fb67a5d
|
9
|
+
with:
|
10
|
+
ruby-version: '3.2'
|
11
|
+
- run: bundle install
|
12
|
+
- run: bundle exec rspec spec
|
data/.gitignore
CHANGED
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.2.1
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @Varpusparvi @francawinter @itsahsiao @lookasc @flowreaction @valeraine
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
phraseapp-in-context-editor-ruby (2.0.0)
|
5
|
+
i18n (~> 1.0)
|
6
|
+
json (~> 2.0)
|
7
|
+
request_store (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actioncable (7.0.7.2)
|
13
|
+
actionpack (= 7.0.7.2)
|
14
|
+
activesupport (= 7.0.7.2)
|
15
|
+
nio4r (~> 2.0)
|
16
|
+
websocket-driver (>= 0.6.1)
|
17
|
+
actionmailbox (7.0.7.2)
|
18
|
+
actionpack (= 7.0.7.2)
|
19
|
+
activejob (= 7.0.7.2)
|
20
|
+
activerecord (= 7.0.7.2)
|
21
|
+
activestorage (= 7.0.7.2)
|
22
|
+
activesupport (= 7.0.7.2)
|
23
|
+
mail (>= 2.7.1)
|
24
|
+
net-imap
|
25
|
+
net-pop
|
26
|
+
net-smtp
|
27
|
+
actionmailer (7.0.7.2)
|
28
|
+
actionpack (= 7.0.7.2)
|
29
|
+
actionview (= 7.0.7.2)
|
30
|
+
activejob (= 7.0.7.2)
|
31
|
+
activesupport (= 7.0.7.2)
|
32
|
+
mail (~> 2.5, >= 2.5.4)
|
33
|
+
net-imap
|
34
|
+
net-pop
|
35
|
+
net-smtp
|
36
|
+
rails-dom-testing (~> 2.0)
|
37
|
+
actionpack (7.0.7.2)
|
38
|
+
actionview (= 7.0.7.2)
|
39
|
+
activesupport (= 7.0.7.2)
|
40
|
+
rack (~> 2.0, >= 2.2.4)
|
41
|
+
rack-test (>= 0.6.3)
|
42
|
+
rails-dom-testing (~> 2.0)
|
43
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
44
|
+
actiontext (7.0.7.2)
|
45
|
+
actionpack (= 7.0.7.2)
|
46
|
+
activerecord (= 7.0.7.2)
|
47
|
+
activestorage (= 7.0.7.2)
|
48
|
+
activesupport (= 7.0.7.2)
|
49
|
+
globalid (>= 0.6.0)
|
50
|
+
nokogiri (>= 1.8.5)
|
51
|
+
actionview (7.0.7.2)
|
52
|
+
activesupport (= 7.0.7.2)
|
53
|
+
builder (~> 3.1)
|
54
|
+
erubi (~> 1.4)
|
55
|
+
rails-dom-testing (~> 2.0)
|
56
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
57
|
+
activejob (7.0.7.2)
|
58
|
+
activesupport (= 7.0.7.2)
|
59
|
+
globalid (>= 0.3.6)
|
60
|
+
activemodel (7.0.7.2)
|
61
|
+
activesupport (= 7.0.7.2)
|
62
|
+
activerecord (7.0.7.2)
|
63
|
+
activemodel (= 7.0.7.2)
|
64
|
+
activesupport (= 7.0.7.2)
|
65
|
+
activestorage (7.0.7.2)
|
66
|
+
actionpack (= 7.0.7.2)
|
67
|
+
activejob (= 7.0.7.2)
|
68
|
+
activerecord (= 7.0.7.2)
|
69
|
+
activesupport (= 7.0.7.2)
|
70
|
+
marcel (~> 1.0)
|
71
|
+
mini_mime (>= 1.1.0)
|
72
|
+
activesupport (7.0.7.2)
|
73
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
74
|
+
i18n (>= 1.6, < 2)
|
75
|
+
minitest (>= 5.1)
|
76
|
+
tzinfo (~> 2.0)
|
77
|
+
addressable (2.8.5)
|
78
|
+
public_suffix (>= 2.0.2, < 6.0)
|
79
|
+
async (2.6.4)
|
80
|
+
console (~> 1.10)
|
81
|
+
fiber-annotation
|
82
|
+
io-event (~> 1.1)
|
83
|
+
timers (~> 4.1)
|
84
|
+
async-http (0.60.2)
|
85
|
+
async (>= 1.25)
|
86
|
+
async-io (>= 1.28)
|
87
|
+
async-pool (>= 0.2)
|
88
|
+
protocol-http (~> 0.24.0)
|
89
|
+
protocol-http1 (~> 0.15.0)
|
90
|
+
protocol-http2 (~> 0.15.0)
|
91
|
+
traces (>= 0.10.0)
|
92
|
+
async-http-faraday (0.12.0)
|
93
|
+
async-http (~> 0.42)
|
94
|
+
faraday
|
95
|
+
async-io (1.35.0)
|
96
|
+
async
|
97
|
+
async-pool (0.4.0)
|
98
|
+
async (>= 1.25)
|
99
|
+
builder (3.2.4)
|
100
|
+
concurrent-ruby (1.2.2)
|
101
|
+
console (1.23.2)
|
102
|
+
fiber-annotation
|
103
|
+
fiber-local
|
104
|
+
crass (1.0.6)
|
105
|
+
date (3.3.3)
|
106
|
+
diff-lcs (1.5.0)
|
107
|
+
erubi (1.12.0)
|
108
|
+
faraday (2.7.10)
|
109
|
+
faraday-net_http (>= 2.0, < 3.1)
|
110
|
+
ruby2_keywords (>= 0.0.4)
|
111
|
+
faraday-http-cache (2.5.0)
|
112
|
+
faraday (>= 0.8)
|
113
|
+
faraday-net_http (3.0.2)
|
114
|
+
fiber-annotation (0.2.0)
|
115
|
+
fiber-local (1.0.0)
|
116
|
+
github_changelog_generator (1.16.4)
|
117
|
+
activesupport
|
118
|
+
async (>= 1.25.0)
|
119
|
+
async-http-faraday
|
120
|
+
faraday-http-cache
|
121
|
+
multi_json
|
122
|
+
octokit (~> 4.6)
|
123
|
+
rainbow (>= 2.2.1)
|
124
|
+
rake (>= 10.0)
|
125
|
+
globalid (1.2.0)
|
126
|
+
activesupport (>= 6.1)
|
127
|
+
i18n (1.14.1)
|
128
|
+
concurrent-ruby (~> 1.0)
|
129
|
+
io-event (1.3.2)
|
130
|
+
json (2.6.3)
|
131
|
+
loofah (2.21.3)
|
132
|
+
crass (~> 1.0.2)
|
133
|
+
nokogiri (>= 1.12.0)
|
134
|
+
mail (2.8.1)
|
135
|
+
mini_mime (>= 0.1.1)
|
136
|
+
net-imap
|
137
|
+
net-pop
|
138
|
+
net-smtp
|
139
|
+
marcel (1.0.2)
|
140
|
+
method_source (1.0.0)
|
141
|
+
mini_mime (1.1.5)
|
142
|
+
minitest (5.19.0)
|
143
|
+
multi_json (1.15.0)
|
144
|
+
net-imap (0.3.7)
|
145
|
+
date
|
146
|
+
net-protocol
|
147
|
+
net-pop (0.1.2)
|
148
|
+
net-protocol
|
149
|
+
net-protocol (0.2.1)
|
150
|
+
timeout
|
151
|
+
net-smtp (0.3.3)
|
152
|
+
net-protocol
|
153
|
+
nio4r (2.5.9)
|
154
|
+
nokogiri (1.15.4-arm64-darwin)
|
155
|
+
racc (~> 1.4)
|
156
|
+
octokit (4.25.1)
|
157
|
+
faraday (>= 1, < 3)
|
158
|
+
sawyer (~> 0.9)
|
159
|
+
protocol-hpack (1.4.2)
|
160
|
+
protocol-http (0.24.7)
|
161
|
+
protocol-http1 (0.15.1)
|
162
|
+
protocol-http (~> 0.22)
|
163
|
+
protocol-http2 (0.15.1)
|
164
|
+
protocol-hpack (~> 1.4)
|
165
|
+
protocol-http (~> 0.18)
|
166
|
+
public_suffix (5.0.3)
|
167
|
+
racc (1.7.1)
|
168
|
+
rack (2.2.8)
|
169
|
+
rack-test (2.1.0)
|
170
|
+
rack (>= 1.3)
|
171
|
+
rails (7.0.7.2)
|
172
|
+
actioncable (= 7.0.7.2)
|
173
|
+
actionmailbox (= 7.0.7.2)
|
174
|
+
actionmailer (= 7.0.7.2)
|
175
|
+
actionpack (= 7.0.7.2)
|
176
|
+
actiontext (= 7.0.7.2)
|
177
|
+
actionview (= 7.0.7.2)
|
178
|
+
activejob (= 7.0.7.2)
|
179
|
+
activemodel (= 7.0.7.2)
|
180
|
+
activerecord (= 7.0.7.2)
|
181
|
+
activestorage (= 7.0.7.2)
|
182
|
+
activesupport (= 7.0.7.2)
|
183
|
+
bundler (>= 1.15.0)
|
184
|
+
railties (= 7.0.7.2)
|
185
|
+
rails-dom-testing (2.2.0)
|
186
|
+
activesupport (>= 5.0.0)
|
187
|
+
minitest
|
188
|
+
nokogiri (>= 1.6)
|
189
|
+
rails-html-sanitizer (1.6.0)
|
190
|
+
loofah (~> 2.21)
|
191
|
+
nokogiri (~> 1.14)
|
192
|
+
railties (7.0.7.2)
|
193
|
+
actionpack (= 7.0.7.2)
|
194
|
+
activesupport (= 7.0.7.2)
|
195
|
+
method_source
|
196
|
+
rake (>= 12.2)
|
197
|
+
thor (~> 1.0)
|
198
|
+
zeitwerk (~> 2.5)
|
199
|
+
rainbow (3.1.1)
|
200
|
+
rake (13.0.6)
|
201
|
+
request_store (1.5.1)
|
202
|
+
rack (>= 1.4)
|
203
|
+
rspec (3.12.0)
|
204
|
+
rspec-core (~> 3.12.0)
|
205
|
+
rspec-expectations (~> 3.12.0)
|
206
|
+
rspec-mocks (~> 3.12.0)
|
207
|
+
rspec-core (3.12.2)
|
208
|
+
rspec-support (~> 3.12.0)
|
209
|
+
rspec-expectations (3.12.3)
|
210
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
211
|
+
rspec-support (~> 3.12.0)
|
212
|
+
rspec-mocks (3.12.6)
|
213
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
214
|
+
rspec-support (~> 3.12.0)
|
215
|
+
rspec-support (3.12.1)
|
216
|
+
ruby2_keywords (0.0.5)
|
217
|
+
sawyer (0.9.2)
|
218
|
+
addressable (>= 2.3.5)
|
219
|
+
faraday (>= 0.17.3, < 3)
|
220
|
+
thor (1.2.2)
|
221
|
+
timeout (0.4.0)
|
222
|
+
timers (4.3.5)
|
223
|
+
traces (0.11.1)
|
224
|
+
tzinfo (2.0.6)
|
225
|
+
concurrent-ruby (~> 1.0)
|
226
|
+
websocket-driver (0.7.6)
|
227
|
+
websocket-extensions (>= 0.1.0)
|
228
|
+
websocket-extensions (0.1.5)
|
229
|
+
zeitwerk (2.6.11)
|
230
|
+
|
231
|
+
PLATFORMS
|
232
|
+
arm64-darwin-22
|
233
|
+
|
234
|
+
DEPENDENCIES
|
235
|
+
github_changelog_generator (~> 1.16)
|
236
|
+
phraseapp-in-context-editor-ruby!
|
237
|
+
rails (~> 7.0)
|
238
|
+
rspec (~> 3.0)
|
239
|
+
|
240
|
+
BUNDLED WITH
|
241
|
+
2.4.19
|
data/Guardfile
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard
|
5
|
-
watch(
|
4
|
+
guard "bundler" do
|
5
|
+
watch("Gemfile")
|
6
6
|
# Uncomment next line if Gemfile contain `gemspec' command
|
7
7
|
# watch(/^.+\.gemspec/)
|
8
8
|
end
|
9
9
|
|
10
|
-
guard
|
10
|
+
guard "rspec" do
|
11
11
|
watch(%r{^spec/.+_spec\.rb$})
|
12
|
-
watch(%r{^lib/(.+)\.rb$})
|
13
|
-
watch(
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
watch("spec/spec_helper.rb") { "spec" }
|
14
14
|
|
15
15
|
# Rails example
|
16
|
-
watch(%r{^app/(.+)\.rb$})
|
17
|
-
watch(%r{^app/(.*)(\.erb|\.haml)$})
|
18
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$})
|
19
|
-
watch(%r{^spec/support/(.+)\.rb$})
|
20
|
-
watch(
|
21
|
-
watch(
|
16
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
17
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
18
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
19
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
20
|
+
watch("config/routes.rb") { "spec/routing" }
|
21
|
+
watch("app/controllers/application_controller.rb") { "spec/controllers" }
|
22
22
|
|
23
23
|
# Capybara features specs
|
24
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml)$})
|
24
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
25
25
|
|
26
26
|
# Turnip features and steps
|
27
27
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
28
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})
|
28
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" }
|
29
29
|
end
|
data/README.md
CHANGED
@@ -1,92 +1,122 @@
|
|
1
|
-
#
|
1
|
+
# phraseapp-in-context-editor-ruby
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
|
5
|
-
|
5
|
+
**phraseapp-in-context-editor-ruby** is the official library for integrating [Phrase Strings In-Context Editor](https://support.phrase.com/hc/en-us/articles/5784095916188-In-Context-Editor-Strings) with [i18n](https://github.com/ruby-i18n/i18n) in your Ruby application.
|
6
6
|
|
7
|
-
|
7
|
+
## :scroll: Documentation
|
8
8
|
|
9
|
-
|
9
|
+
### Prerequisites
|
10
10
|
|
11
|
-
|
11
|
+
To use phraseapp-in-context-editor-ruby with your application you have to:
|
12
12
|
|
13
|
-
|
13
|
+
* Sign up for a Phrase account: [https://app.phrase.com/signup](https://app.phrase.com/signup)
|
14
|
+
* Use the excellent [i18n](https://github.com/ruby-i18n/i18n) gem also used by [Rails](https://guides.rubyonrails.org/i18n.html)
|
14
15
|
|
15
|
-
|
16
|
+
### Demo
|
16
17
|
|
17
|
-
|
18
|
+
You can find a demo project in the `examples/demo` folder, just run `bundle && rails s` and head to `http://127.0.0.1:3000`
|
19
|
+
Login via the demo credentials `demo@phrase.com` / `phrase`
|
18
20
|
|
19
|
-
###
|
21
|
+
### Installation
|
20
22
|
|
21
|
-
|
23
|
+
#### NOTE: You can not use the old version of the ICE with integration versions of >2.0.0, you have to instead use 1.x.x versions as before
|
24
|
+
#### via Gem
|
22
25
|
|
23
|
-
|
26
|
+
```bash
|
27
|
+
gem install phraseapp-in-context-editor-ruby
|
28
|
+
```
|
29
|
+
#### via Bundler
|
24
30
|
|
25
|
-
|
31
|
+
Add it to your `Gemfile`
|
26
32
|
|
27
|
-
|
33
|
+
```
|
34
|
+
gem 'phraseapp-in-context-editor-ruby
|
35
|
+
```
|
28
36
|
|
29
|
-
|
37
|
+
#### Build from source
|
30
38
|
|
31
|
-
|
39
|
+
You can also build it directly from source to get the latest and greatest:
|
32
40
|
|
33
|
-
|
41
|
+
```bash
|
42
|
+
bundle && gem build
|
43
|
+
```
|
34
44
|
|
35
|
-
|
45
|
+
#### Initialized config file
|
36
46
|
|
37
|
-
|
47
|
+
Create the initializer file by executing the Rails generator:
|
38
48
|
|
39
|
-
|
49
|
+
```bash
|
50
|
+
rails generate phraseapp_in_context_editor:install --account_id=<YOUR_ACCOUNT_ID> --project-id=<YOUR_PROJECT_ID>
|
51
|
+
```
|
40
52
|
|
41
|
-
|
53
|
+
### Development
|
42
54
|
|
43
|
-
|
55
|
+
```bash
|
56
|
+
# install deps
|
57
|
+
bundle
|
58
|
+
```
|
44
59
|
|
45
|
-
|
60
|
+
#### Configure
|
46
61
|
|
47
|
-
|
62
|
+
Add the following Ruby snippet to your rails `app/views//layouts/application.html.erb`
|
48
63
|
|
49
|
-
|
64
|
+
```
|
65
|
+
<%= load_in_context_editor %>
|
66
|
+
```
|
50
67
|
|
51
|
-
|
68
|
+
And the following config to your `/config/initializers/phraseapp_in_context_editor.rb`
|
52
69
|
|
53
|
-
|
70
|
+
```ruby
|
71
|
+
config.enabled = true
|
72
|
+
config.project_id = "YOUR_PROJECT_ID"
|
73
|
+
config.account_id = "YOUR_ACCOUNT_ID"
|
74
|
+
config.datacenter = "eu"
|
75
|
+
```
|
54
76
|
|
55
|
-
|
77
|
+
You can find the Project-ID in the Project overview in the PhraseApp Translation Center.
|
78
|
+
You can find the Account-ID in the Organization page in the PhraseApp Translation Center.
|
56
79
|
|
57
|
-
|
80
|
+
If this does not work for you, you can also integrate the [JavaScript snippet manually](https://help.phrase.com/help/integrate-in-context-editor-into-any-web-framework).
|
58
81
|
|
59
|
-
|
82
|
+
Old version of the ICE is not available since version 2.0.0. If you still would rather use the old version, please go back to 1.x.x versions.
|
60
83
|
|
61
|
-
|
84
|
+
#### Using the US Datacenter with ICE
|
62
85
|
|
63
|
-
|
64
|
-
|
65
|
-
|
86
|
+
In addition to the settings in your `config/initializers/phraseapp_in_context_editor.rb`, set the US datacenter to enable the ICE to work with the US endpoints.
|
87
|
+
```ruby
|
88
|
+
config.enabled = true
|
89
|
+
config.project_id = "YOUR_PROJECT_ID"
|
90
|
+
config.account_id = "YOUR_ACCOUNT_ID"
|
91
|
+
config.datacenter = "us"
|
66
92
|
```
|
67
93
|
|
68
|
-
|
94
|
+
### Browser support
|
69
95
|
|
70
|
-
|
71
|
-
$ rvm osx-ssl-certs status all
|
72
|
-
$ rvm osx-ssl-certs update all
|
73
|
-
````
|
96
|
+
This library might not work out of the box for some older browser or IE11. We recommend to add [Babel](https://github.com/babel/babel) to the build pipeline if those browser need to be supported.
|
74
97
|
|
75
|
-
|
98
|
+
### How does it work
|
76
99
|
|
77
|
-
|
78
|
-
|
100
|
+
The library adds custom functionality to the `i18n` package. When `config.enabled = true` this gem modifies the outcoming values from translation functions to present a format which the ICE can read.
|
101
|
+
|
102
|
+
### Test
|
103
|
+
|
104
|
+
Run unit tests using jest:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
rspec
|
79
108
|
```
|
80
109
|
|
81
|
-
|
110
|
+
## :white_check_mark: Commits & Pull Requests
|
111
|
+
|
112
|
+
We welcome anyone who wants to contribute to our codebase, so if you notice something, feel free to open a Pull Request! However, we ask that you please use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for your commit messages and titles when opening a Pull Request.
|
113
|
+
|
114
|
+
Example: `chore: Update README`
|
115
|
+
|
116
|
+
## :question: Issues, Questions, Support
|
82
117
|
|
118
|
+
Please use [GitHub issues](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues) to share your problem, and we will do our best to answer any questions or to support you in finding a solution.
|
83
119
|
|
84
|
-
##
|
85
|
-
* [Phrase Help Center](https://help.phrase.com/)
|
86
|
-
* [Software Translation Management with Phrase](https://phrase.com/features)
|
87
|
-
* [Contact us](https://phrase.com/contact)
|
120
|
+
## :memo: Changelog
|
88
121
|
|
89
|
-
|
90
|
-
* [Phrase API Documentation](https://developers.phrase.com/api/)
|
91
|
-
* [In-Context-Editor Demo](https://phrase.com/demo)
|
92
|
-
* [Localization Guides and Software Translation Best Practices](https://phrase.com/blog/)
|
122
|
+
Detailed changes for each release are documented in the [changelog](https://github.com/phrase/phraseapp-in-context-editor-ruby/releases).
|
data/RELEASING.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Release
|
2
|
+
|
3
|
+
1. Bump the version to the desired number in lib/phraseapp-in-context-editor-ruby/version.rb. Make sure you're following semantic versioning.
|
4
|
+
2. Run `bundle` and commit Gemfile.lock including the new version of the gem
|
5
|
+
3. Make sure the tests pass
|
6
|
+
4. Tag the new version on GitHub
|
7
|
+
5. Update the CHANGELOG by running `$ github_changelog_generator` and commit the new `CHANGELOG`
|
8
|
+
6. Build the gem by running `gem build phraseapp-in-context-editor-ruby.gemspec`
|
9
|
+
7. Push the gem to Rubygems by running `gem push phraseapp-in-context-editor-ruby-<VERSION>.gem`
|
10
|
+
8. Done!
|
@@ -1,21 +1,15 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
1
|
module PhraseappInContextEditor
|
4
2
|
module Generators
|
5
3
|
class InstallGenerator < Rails::Generators::Base
|
6
4
|
source_root File.expand_path("../templates", __FILE__)
|
7
5
|
|
8
|
-
desc "Creates a
|
9
|
-
class_option :
|
10
|
-
class_option :project_id, type: :string, desc: "Your
|
6
|
+
desc "Creates a Phrase In-Context-Editor initializer for your application."
|
7
|
+
class_option :account_id, type: :string, desc: "Your Phrase account id", required: true
|
8
|
+
class_option :project_id, type: :string, desc: "Your Phrase project id", required: true
|
11
9
|
|
12
10
|
def copy_initializer
|
13
11
|
template "phraseapp_in_context_editor.rb", "config/initializers/phraseapp_in_context_editor.rb"
|
14
12
|
end
|
15
|
-
|
16
|
-
def show_readme
|
17
|
-
readme "README" if behavior == :invoke
|
18
|
-
end
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
@@ -2,26 +2,18 @@ PhraseApp::InContextEditor.configure do |config|
|
|
2
2
|
# Enable or disable the In-Context-Editor in general
|
3
3
|
config.enabled = true
|
4
4
|
|
5
|
-
#
|
6
|
-
# in
|
7
|
-
#
|
8
|
-
# page (https://phraseapp.com/projects)
|
5
|
+
# Configure with your project id and account id. You can find the
|
6
|
+
# project id in your project settings and account id in your account
|
7
|
+
# settings (https://app.phrase.com/)
|
9
8
|
config.project_id = "<%= options[:project_id] %>"
|
9
|
+
config.account_id = "<%= options[:account_id] %>"
|
10
|
+
config.datacenter = "eu"
|
10
11
|
|
11
|
-
#
|
12
|
-
# in Translation Center or via the Authorizations API
|
13
|
-
# (https://developers.phraseapp.com/api/#authorizations).
|
14
|
-
config.access_token = "<%= options[:access_token] %>"
|
15
|
-
|
16
|
-
# Configure an array of key names that should not be handled
|
17
|
-
# by the In-Context-Editor.
|
18
|
-
config.ignored_keys = ["number.*", "breadcrumb.*"]
|
19
|
-
|
20
|
-
# PhraseApp uses decorators to generate a unique identification key
|
12
|
+
# Phrase uses decorators to generate a unique identification key
|
21
13
|
# in context of your document. However, this might result in conflicts
|
22
14
|
# with other libraries (e.g. client-side template engines) that use a similar syntax.
|
23
15
|
# If you encounter this problem, you might want to change this decorator pattern.
|
24
|
-
# More information: https://help.
|
25
|
-
# config.prefix = "
|
26
|
-
# config.suffix = "__
|
16
|
+
# More information: https://help.phrase.com/hc/en-us/articles/5784095916188-In-Context-Editor-Strings-
|
17
|
+
# config.prefix = "[[__"
|
18
|
+
# config.suffix = "__]]"
|
27
19
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
|
1
|
+
require "phraseapp-in-context-editor-ruby/delegate/fast_gettext"
|
2
2
|
|
3
|
-
|
3
|
+
if defined? FastGettext::Translation
|
4
|
+
module FastGettext
|
5
|
+
module Translation
|
6
|
+
def __with_phraseapp(*args)
|
7
|
+
PhraseApp::InContextEditor::Delegate::FastGettext.new(:_, *args)
|
8
|
+
end
|
9
|
+
alias_method :__without_phraseapp, :_
|
10
|
+
alias_method :_, :__with_phraseapp
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
alias_method :__without_phraseapp, :_
|
11
|
-
alias_method :_, :__with_phraseapp
|
12
|
-
|
13
|
-
def n__with_phraseapp(*args)
|
14
|
-
PhraseApp::InContextEditor::Delegate::FastGettext.new(:n_, *args)
|
15
|
-
end
|
16
|
-
alias_method :n__without_phraseapp, :n_
|
17
|
-
alias_method :n_, :n__with_phraseapp
|
12
|
+
def n__with_phraseapp(*args)
|
13
|
+
PhraseApp::InContextEditor::Delegate::FastGettext.new(:n_, *args)
|
14
|
+
end
|
15
|
+
alias_method :n__without_phraseapp, :n_
|
16
|
+
alias_method :n_, :n__with_phraseapp
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
def s__with_phraseapp(*args)
|
19
|
+
PhraseApp::InContextEditor::Delegate::FastGettext.new(:s_, *args)
|
20
|
+
end
|
21
|
+
alias_method :s__without_phraseapp, :s_
|
22
|
+
alias_method :s_, :s__with_phraseapp
|
21
23
|
end
|
22
|
-
alias_method :s__without_phraseapp, :s_
|
23
|
-
alias_method :s_, :s__with_phraseapp
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
if defined?(I18n)
|
2
|
+
module I18n
|
3
|
+
class << self
|
4
|
+
def translate_with_phraseapp(*args)
|
5
|
+
PhraseApp::InContextEditor.backend.translate(*args)
|
6
|
+
end
|
7
|
+
alias_method :translate_without_phraseapp, :translate
|
8
|
+
alias_method :translate, :translate_with_phraseapp
|
9
|
+
alias_method :t, :translate
|
7
10
|
end
|
8
|
-
alias_method :translate_without_phraseapp, :translate
|
9
|
-
alias_method :translate, :translate_with_phraseapp
|
10
|
-
alias_method :t, :translate
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|