phraseapp-in-context-editor-ruby 1.4.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +18 -0
  3. data/.github/workflows/close_inactive_issues.yml +18 -0
  4. data/.github/workflows/release.yml +28 -0
  5. data/.github/workflows/test.yml +8 -9
  6. data/.gitignore +1 -1
  7. data/.tool-versions +1 -1
  8. data/CHANGELOG.md +9 -105
  9. data/CODEOWNERS +1 -0
  10. data/Gemfile +1 -1
  11. data/Gemfile.lock +244 -0
  12. data/Guardfile +13 -13
  13. data/README.md +81 -51
  14. data/RELEASING.md +3 -0
  15. data/docs/CHANGELOG.md +116 -0
  16. data/examples/demo/.gitattributes +7 -0
  17. data/examples/demo/.gitignore +35 -0
  18. data/examples/demo/Gemfile +74 -0
  19. data/examples/demo/Gemfile.lock +268 -0
  20. data/examples/demo/README.md +5 -0
  21. data/examples/demo/Rakefile +6 -0
  22. data/examples/demo/app/assets/config/manifest.js +4 -0
  23. data/examples/demo/app/assets/images/.keep +0 -0
  24. data/examples/demo/app/assets/stylesheets/application.css +15 -0
  25. data/examples/demo/app/channels/application_cable/channel.rb +4 -0
  26. data/examples/demo/app/channels/application_cable/connection.rb +4 -0
  27. data/examples/demo/app/controllers/application_controller.rb +2 -0
  28. data/examples/demo/app/controllers/concerns/.keep +0 -0
  29. data/examples/demo/app/controllers/main_controller.rb +4 -0
  30. data/examples/demo/app/helpers/application_helper.rb +2 -0
  31. data/examples/demo/app/helpers/main_helper.rb +2 -0
  32. data/examples/demo/app/javascript/application.js +3 -0
  33. data/examples/demo/app/javascript/controllers/application.js +9 -0
  34. data/examples/demo/app/javascript/controllers/hello_controller.js +7 -0
  35. data/examples/demo/app/javascript/controllers/index.js +11 -0
  36. data/examples/demo/app/jobs/application_job.rb +7 -0
  37. data/examples/demo/app/mailers/application_mailer.rb +4 -0
  38. data/examples/demo/app/models/application_record.rb +3 -0
  39. data/examples/demo/app/models/concerns/.keep +0 -0
  40. data/examples/demo/app/views/layouts/application.html.erb +17 -0
  41. data/examples/demo/app/views/layouts/mailer.html.erb +13 -0
  42. data/examples/demo/app/views/layouts/mailer.text.erb +1 -0
  43. data/examples/demo/app/views/main/index.html.erb +8 -0
  44. data/examples/demo/bin/bundle +109 -0
  45. data/examples/demo/bin/importmap +4 -0
  46. data/examples/demo/bin/rails +4 -0
  47. data/examples/demo/bin/rake +4 -0
  48. data/examples/demo/bin/setup +33 -0
  49. data/examples/demo/config/application.rb +22 -0
  50. data/examples/demo/config/boot.rb +4 -0
  51. data/examples/demo/config/cable.yml +10 -0
  52. data/examples/demo/config/credentials.yml.enc +1 -0
  53. data/examples/demo/config/database.yml +25 -0
  54. data/examples/demo/config/environment.rb +5 -0
  55. data/examples/demo/config/environments/development.rb +70 -0
  56. data/examples/demo/config/environments/production.rb +93 -0
  57. data/examples/demo/config/environments/test.rb +60 -0
  58. data/examples/demo/config/importmap.rb +7 -0
  59. data/examples/demo/config/initializers/assets.rb +12 -0
  60. data/examples/demo/config/initializers/content_security_policy.rb +25 -0
  61. data/examples/demo/config/initializers/filter_parameter_logging.rb +8 -0
  62. data/examples/demo/config/initializers/inflections.rb +16 -0
  63. data/examples/demo/config/initializers/permissions_policy.rb +11 -0
  64. data/examples/demo/config/initializers/phraseapp_in_context_editor.rb +20 -0
  65. data/examples/demo/config/locales/en.yml +38 -0
  66. data/examples/demo/config/puma.rb +43 -0
  67. data/examples/demo/config/routes.rb +6 -0
  68. data/examples/demo/config/storage.yml +34 -0
  69. data/examples/demo/config.ru +6 -0
  70. data/examples/demo/db/seeds.rb +7 -0
  71. data/examples/demo/lib/assets/.keep +0 -0
  72. data/examples/demo/lib/tasks/.keep +0 -0
  73. data/examples/demo/log/.keep +0 -0
  74. data/examples/demo/public/404.html +67 -0
  75. data/examples/demo/public/422.html +67 -0
  76. data/examples/demo/public/500.html +66 -0
  77. data/examples/demo/public/apple-touch-icon-precomposed.png +0 -0
  78. data/examples/demo/public/apple-touch-icon.png +0 -0
  79. data/examples/demo/public/favicon.ico +0 -0
  80. data/examples/demo/public/robots.txt +1 -0
  81. data/examples/demo/storage/.keep +0 -0
  82. data/examples/demo/test/application_system_test_case.rb +5 -0
  83. data/examples/demo/test/channels/application_cable/connection_test.rb +11 -0
  84. data/examples/demo/test/controllers/.keep +0 -0
  85. data/examples/demo/test/controllers/main_controller_test.rb +8 -0
  86. data/examples/demo/test/fixtures/files/.keep +0 -0
  87. data/examples/demo/test/helpers/.keep +0 -0
  88. data/examples/demo/test/integration/.keep +0 -0
  89. data/examples/demo/test/mailers/.keep +0 -0
  90. data/examples/demo/test/models/.keep +0 -0
  91. data/examples/demo/test/system/.keep +0 -0
  92. data/examples/demo/test/test_helper.rb +13 -0
  93. data/examples/demo/tmp/.keep +0 -0
  94. data/examples/demo/tmp/pids/.keep +0 -0
  95. data/examples/demo/tmp/storage/.keep +0 -0
  96. data/examples/demo/vendor/.keep +0 -0
  97. data/examples/demo/vendor/javascript/.keep +0 -0
  98. data/lib/generators/phraseapp_in_context_editor/install_generator.rb +3 -9
  99. data/lib/generators/phraseapp_in_context_editor/templates/phraseapp_in_context_editor.rb +9 -17
  100. data/lib/phraseapp-in-context-editor-ruby/adapters/fast_gettext.rb +20 -20
  101. data/lib/phraseapp-in-context-editor-ruby/adapters/i18n.rb +10 -10
  102. data/lib/phraseapp-in-context-editor-ruby/backend_service.rb +12 -99
  103. data/lib/phraseapp-in-context-editor-ruby/config.rb +13 -49
  104. data/lib/phraseapp-in-context-editor-ruby/delegate/fast_gettext.rb +13 -15
  105. data/lib/phraseapp-in-context-editor-ruby/delegate/i18n_delegate.rb +4 -50
  106. data/lib/phraseapp-in-context-editor-ruby/delegate.rb +13 -14
  107. data/lib/phraseapp-in-context-editor-ruby/engine.rb +5 -6
  108. data/lib/phraseapp-in-context-editor-ruby/version.rb +1 -3
  109. data/lib/phraseapp-in-context-editor-ruby/view_helpers.rb +26 -19
  110. data/lib/phraseapp-in-context-editor-ruby.rb +17 -52
  111. data/package-lock.json +6576 -0
  112. data/package.json +13 -0
  113. data/phraseapp-in-context-editor-ruby.gemspec +19 -32
  114. data/release.config.js +10 -0
  115. metadata +113 -97
  116. data/lib/generators/phraseapp_in_context_editor/templates/README +0 -10
  117. data/lib/phraseapp-in-context-editor-ruby/api_collection.rb +0 -41
  118. data/lib/phraseapp-in-context-editor-ruby/api_wrapper.rb +0 -59
  119. data/lib/phraseapp-in-context-editor-ruby/cache.rb +0 -37
  120. data/lib/phraseapp-in-context-editor-ruby/displayable_key_identifier.rb +0 -46
  121. data/lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb +0 -44
  122. data/lib/phraseapp-in-context-editor-ruby/hash_flattener.rb +0 -53
  123. data/lib/phraseapp-in-context-editor-ruby/key_names_cache.rb +0 -53
data/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "scripts": {
3
+ "release": "semantic-release"
4
+ },
5
+ "devDependencies": {
6
+ "@semantic-release/commit-analyzer": "^8.0.1",
7
+ "@semantic-release/release-notes-generator": "^9.0.1",
8
+ "@semantic-release/changelog": "^5.0.1",
9
+ "@semantic-release/git": "^9.0.0",
10
+ "semantic-release": "^17.0.7",
11
+ "semantic-release-rubygem": "^1.2.0"
12
+ }
13
+ }
@@ -1,43 +1,30 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib/', __FILE__)
3
- $:.unshift lib unless $:.include?(lib)
1
+ # frozen_string_literal: true
4
2
 
5
- require 'phraseapp-in-context-editor-ruby/version'
3
+ require "./lib/phraseapp-in-context-editor-ruby/version"
6
4
 
7
5
  Gem::Specification.new do |s|
8
6
  s.name = "phraseapp-in-context-editor-ruby"
9
- s.version = PhraseApp::InContextEditor::VERSION
7
+ s.version = PhraseApp::VERSION
10
8
  s.platform = Gem::Platform::RUBY
11
- s.required_ruby_version = '>= 2.1'
12
- s.authors = ["Dynport GmbH"]
9
+ s.required_ruby_version = ">= 3.1.0"
10
+ s.authors = ["Phrase"]
13
11
  s.email = ["info@phrase.com"]
14
12
  s.homepage = "https://phrase.com"
15
- s.summary = %q{Translation management solution for web and mobile applications}
16
- s.licenses = ['MIT']
17
- s.description = %q{Phrase In-Context-Editor allows you to edit translations directly on the website. More information: phrase.com}
13
+ s.summary = "Translation management solution for web and mobile applications"
14
+ s.licenses = ["MIT"]
15
+ s.description = "Phrase In-Context-Editor allows you to edit translations directly on the website. More information: phrase.com"
18
16
  s.required_rubygems_version = ">= 1.3.6"
19
- s.rubyforge_project = "phraseapp-in-context-editor-ruby"
20
- git_files = `git ls-files | grep -v spec/`.split("\n") rescue ''
17
+ git_files = begin
18
+ `git ls-files | grep -v spec/`.split("\n")
19
+ rescue
20
+ ""
21
+ end
21
22
  s.files = git_files
22
- s.test_files = s.files.grep(%r{^(spec)/})
23
23
  s.require_paths = ["lib"]
24
- if RUBY_VERSION >= '2.4'
25
- s.add_dependency('json', '>= 1.8', '< 3')
26
- else
27
- s.add_dependency('json', '>= 1.7', '< 3')
28
- end
29
- s.add_dependency('i18n', '>= 0.6')
30
- s.add_dependency('phraseapp-ruby', '~> 1.3')
31
- s.add_dependency('request_store', '~> 1.3')
32
- s.add_development_dependency('rspec', '~> 3.2')
33
- s.add_development_dependency('webmock', '~> 1.21')
34
- s.add_development_dependency('vcr', '~> 2.9')
35
- s.add_development_dependency('timecop', '~> 0.7')
36
- if RUBY_VERSION < '2.2'
37
- s.add_development_dependency('mime-types', '< 3.0') # for 1.9.3 to work
38
- s.add_development_dependency('rails', '~> 4.2')
39
- else
40
- s.add_development_dependency('rails', '>= 4.2', '< 5.1')
41
- end
42
- s.add_development_dependency('github_changelog_generator')
24
+ s.add_dependency("json", "~> 2.0")
25
+ s.add_dependency("i18n", "~> 1.0")
26
+ s.add_dependency("request_store", "~> 1.2")
27
+ s.add_development_dependency("rspec", "~> 3.0")
28
+ s.add_development_dependency("rails", "~> 7.0")
29
+ s.add_development_dependency("github_changelog_generator", "~> 1.16")
43
30
  end
data/release.config.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ "plugins": [
3
+ "@semantic-release/commit-analyzer",
4
+ "@semantic-release/release-notes-generator",
5
+ "@semantic-release/changelog",
6
+ "@semantic-release/git",
7
+ "semantic-release-rubygem",
8
+ ],
9
+ "branches": 'master',
10
+ };
metadata CHANGED
@@ -1,167 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp-in-context-editor-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Dynport GmbH
7
+ - Phrase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-16 00:00:00.000000000 Z
11
+ date: 2024-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.8'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '3'
19
+ version: '2.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '1.8'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '3'
26
+ version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: i18n
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0.6'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0.6'
47
- - !ruby/object:Gem::Dependency
48
- name: phraseapp-ruby
49
29
  requirement: !ruby/object:Gem::Requirement
50
30
  requirements:
51
31
  - - "~>"
52
32
  - !ruby/object:Gem::Version
53
- version: '1.3'
33
+ version: '1.0'
54
34
  type: :runtime
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
38
  - - "~>"
59
39
  - !ruby/object:Gem::Version
60
- version: '1.3'
40
+ version: '1.0'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: request_store
63
43
  requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
45
  - - "~>"
66
46
  - !ruby/object:Gem::Version
67
- version: '1.3'
47
+ version: '1.2'
68
48
  type: :runtime
69
49
  prerelease: false
70
50
  version_requirements: !ruby/object:Gem::Requirement
71
51
  requirements:
72
52
  - - "~>"
73
53
  - !ruby/object:Gem::Version
74
- version: '1.3'
54
+ version: '1.2'
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: rspec
77
57
  requirement: !ruby/object:Gem::Requirement
78
58
  requirements:
79
59
  - - "~>"
80
60
  - !ruby/object:Gem::Version
81
- version: '3.2'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.2'
89
- - !ruby/object:Gem::Dependency
90
- name: webmock
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.21'
61
+ version: '3.0'
96
62
  type: :development
97
63
  prerelease: false
98
64
  version_requirements: !ruby/object:Gem::Requirement
99
65
  requirements:
100
66
  - - "~>"
101
67
  - !ruby/object:Gem::Version
102
- version: '1.21'
68
+ version: '3.0'
103
69
  - !ruby/object:Gem::Dependency
104
- name: vcr
70
+ name: rails
105
71
  requirement: !ruby/object:Gem::Requirement
106
72
  requirements:
107
73
  - - "~>"
108
74
  - !ruby/object:Gem::Version
109
- version: '2.9'
75
+ version: '7.0'
110
76
  type: :development
111
77
  prerelease: false
112
78
  version_requirements: !ruby/object:Gem::Requirement
113
79
  requirements:
114
80
  - - "~>"
115
81
  - !ruby/object:Gem::Version
116
- version: '2.9'
82
+ version: '7.0'
117
83
  - !ruby/object:Gem::Dependency
118
- name: timecop
84
+ name: github_changelog_generator
119
85
  requirement: !ruby/object:Gem::Requirement
120
86
  requirements:
121
87
  - - "~>"
122
88
  - !ruby/object:Gem::Version
123
- version: '0.7'
89
+ version: '1.16'
124
90
  type: :development
125
91
  prerelease: false
126
92
  version_requirements: !ruby/object:Gem::Requirement
127
93
  requirements:
128
94
  - - "~>"
129
95
  - !ruby/object:Gem::Version
130
- version: '0.7'
131
- - !ruby/object:Gem::Dependency
132
- name: rails
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '4.2'
138
- - - "<"
139
- - !ruby/object:Gem::Version
140
- version: '5.1'
141
- type: :development
142
- prerelease: false
143
- version_requirements: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: '4.2'
148
- - - "<"
149
- - !ruby/object:Gem::Version
150
- version: '5.1'
151
- - !ruby/object:Gem::Dependency
152
- name: github_changelog_generator
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- type: :development
159
- prerelease: false
160
- version_requirements: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- version: '0'
96
+ version: '1.16'
165
97
  description: 'Phrase In-Context-Editor allows you to edit translations directly on
166
98
  the website. More information: phrase.com'
167
99
  email:
@@ -170,40 +102,124 @@ executables: []
170
102
  extensions: []
171
103
  extra_rdoc_files: []
172
104
  files:
105
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
106
+ - ".github/workflows/close_inactive_issues.yml"
107
+ - ".github/workflows/release.yml"
173
108
  - ".github/workflows/test.yml"
174
109
  - ".gitignore"
175
110
  - ".package-licenses.yml"
176
111
  - ".tool-versions"
177
112
  - CHANGELOG.md
113
+ - CODEOWNERS
178
114
  - Gemfile
115
+ - Gemfile.lock
179
116
  - Guardfile
180
117
  - LICENSE
181
118
  - README.md
119
+ - RELEASING.md
182
120
  - cacert.pem
183
121
  - config/license-decisions.yml
184
122
  - config/license_finder.yml
123
+ - docs/CHANGELOG.md
124
+ - examples/demo/.gitattributes
125
+ - examples/demo/.gitignore
126
+ - examples/demo/Gemfile
127
+ - examples/demo/Gemfile.lock
128
+ - examples/demo/README.md
129
+ - examples/demo/Rakefile
130
+ - examples/demo/app/assets/config/manifest.js
131
+ - examples/demo/app/assets/images/.keep
132
+ - examples/demo/app/assets/stylesheets/application.css
133
+ - examples/demo/app/channels/application_cable/channel.rb
134
+ - examples/demo/app/channels/application_cable/connection.rb
135
+ - examples/demo/app/controllers/application_controller.rb
136
+ - examples/demo/app/controllers/concerns/.keep
137
+ - examples/demo/app/controllers/main_controller.rb
138
+ - examples/demo/app/helpers/application_helper.rb
139
+ - examples/demo/app/helpers/main_helper.rb
140
+ - examples/demo/app/javascript/application.js
141
+ - examples/demo/app/javascript/controllers/application.js
142
+ - examples/demo/app/javascript/controllers/hello_controller.js
143
+ - examples/demo/app/javascript/controllers/index.js
144
+ - examples/demo/app/jobs/application_job.rb
145
+ - examples/demo/app/mailers/application_mailer.rb
146
+ - examples/demo/app/models/application_record.rb
147
+ - examples/demo/app/models/concerns/.keep
148
+ - examples/demo/app/views/layouts/application.html.erb
149
+ - examples/demo/app/views/layouts/mailer.html.erb
150
+ - examples/demo/app/views/layouts/mailer.text.erb
151
+ - examples/demo/app/views/main/index.html.erb
152
+ - examples/demo/bin/bundle
153
+ - examples/demo/bin/importmap
154
+ - examples/demo/bin/rails
155
+ - examples/demo/bin/rake
156
+ - examples/demo/bin/setup
157
+ - examples/demo/config.ru
158
+ - examples/demo/config/application.rb
159
+ - examples/demo/config/boot.rb
160
+ - examples/demo/config/cable.yml
161
+ - examples/demo/config/credentials.yml.enc
162
+ - examples/demo/config/database.yml
163
+ - examples/demo/config/environment.rb
164
+ - examples/demo/config/environments/development.rb
165
+ - examples/demo/config/environments/production.rb
166
+ - examples/demo/config/environments/test.rb
167
+ - examples/demo/config/importmap.rb
168
+ - examples/demo/config/initializers/assets.rb
169
+ - examples/demo/config/initializers/content_security_policy.rb
170
+ - examples/demo/config/initializers/filter_parameter_logging.rb
171
+ - examples/demo/config/initializers/inflections.rb
172
+ - examples/demo/config/initializers/permissions_policy.rb
173
+ - examples/demo/config/initializers/phraseapp_in_context_editor.rb
174
+ - examples/demo/config/locales/en.yml
175
+ - examples/demo/config/puma.rb
176
+ - examples/demo/config/routes.rb
177
+ - examples/demo/config/storage.yml
178
+ - examples/demo/db/seeds.rb
179
+ - examples/demo/lib/assets/.keep
180
+ - examples/demo/lib/tasks/.keep
181
+ - examples/demo/log/.keep
182
+ - examples/demo/public/404.html
183
+ - examples/demo/public/422.html
184
+ - examples/demo/public/500.html
185
+ - examples/demo/public/apple-touch-icon-precomposed.png
186
+ - examples/demo/public/apple-touch-icon.png
187
+ - examples/demo/public/favicon.ico
188
+ - examples/demo/public/robots.txt
189
+ - examples/demo/storage/.keep
190
+ - examples/demo/test/application_system_test_case.rb
191
+ - examples/demo/test/channels/application_cable/connection_test.rb
192
+ - examples/demo/test/controllers/.keep
193
+ - examples/demo/test/controllers/main_controller_test.rb
194
+ - examples/demo/test/fixtures/files/.keep
195
+ - examples/demo/test/helpers/.keep
196
+ - examples/demo/test/integration/.keep
197
+ - examples/demo/test/mailers/.keep
198
+ - examples/demo/test/models/.keep
199
+ - examples/demo/test/system/.keep
200
+ - examples/demo/test/test_helper.rb
201
+ - examples/demo/tmp/.keep
202
+ - examples/demo/tmp/pids/.keep
203
+ - examples/demo/tmp/storage/.keep
204
+ - examples/demo/vendor/.keep
205
+ - examples/demo/vendor/javascript/.keep
185
206
  - lib/generators/phraseapp_in_context_editor/install_generator.rb
186
- - lib/generators/phraseapp_in_context_editor/templates/README
187
207
  - lib/generators/phraseapp_in_context_editor/templates/phraseapp_in_context_editor.rb
188
208
  - lib/phraseapp-in-context-editor-ruby.rb
189
209
  - lib/phraseapp-in-context-editor-ruby/adapters/fast_gettext.rb
190
210
  - lib/phraseapp-in-context-editor-ruby/adapters/i18n.rb
191
- - lib/phraseapp-in-context-editor-ruby/api_collection.rb
192
- - lib/phraseapp-in-context-editor-ruby/api_wrapper.rb
193
211
  - lib/phraseapp-in-context-editor-ruby/backend_service.rb
194
- - lib/phraseapp-in-context-editor-ruby/cache.rb
195
212
  - lib/phraseapp-in-context-editor-ruby/config.rb
196
213
  - lib/phraseapp-in-context-editor-ruby/delegate.rb
197
214
  - lib/phraseapp-in-context-editor-ruby/delegate/fast_gettext.rb
198
215
  - lib/phraseapp-in-context-editor-ruby/delegate/i18n_delegate.rb
199
- - lib/phraseapp-in-context-editor-ruby/displayable_key_identifier.rb
200
216
  - lib/phraseapp-in-context-editor-ruby/engine.rb
201
- - lib/phraseapp-in-context-editor-ruby/fallback_keys_fetcher.rb
202
- - lib/phraseapp-in-context-editor-ruby/hash_flattener.rb
203
- - lib/phraseapp-in-context-editor-ruby/key_names_cache.rb
204
217
  - lib/phraseapp-in-context-editor-ruby/version.rb
205
218
  - lib/phraseapp-in-context-editor-ruby/view_helpers.rb
219
+ - package-lock.json
220
+ - package.json
206
221
  - phraseapp-in-context-editor-ruby.gemspec
222
+ - release.config.js
207
223
  homepage: https://phrase.com
208
224
  licenses:
209
225
  - MIT
@@ -216,14 +232,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
232
  requirements:
217
233
  - - ">="
218
234
  - !ruby/object:Gem::Version
219
- version: '2.1'
235
+ version: 3.1.0
220
236
  required_rubygems_version: !ruby/object:Gem::Requirement
221
237
  requirements:
222
238
  - - ">="
223
239
  - !ruby/object:Gem::Version
224
240
  version: 1.3.6
225
241
  requirements: []
226
- rubygems_version: 3.2.3
242
+ rubygems_version: 3.4.10
227
243
  signing_key:
228
244
  specification_version: 4
229
245
  summary: Translation management solution for web and mobile applications
@@ -1,10 +0,0 @@
1
- ===============================================================================
2
- Welcome to PhraseApp!
3
-
4
- PhraseApp is the translation management solution for web and mobile applications. Collaborate with your team, find professional translators and stay on top of the process.
5
-
6
- How awesome would it be if translators could simply browse your website and edit text along the way? Our In-Context Editor offers just that. It provides translators with useful contextual information which improves overall translation quality.
7
-
8
- Login: https://phraseapp.com/account/login
9
- Documentation: https://help.phraseapp.com/translate-website-and-app-content/use-in-context-editor-to-translate/translate-directly-on-your-website
10
- ===============================================================================
@@ -1,41 +0,0 @@
1
- module PhraseApp
2
- module InContextEditor
3
- class ApiCollection
4
- def initialize(api_client, action, ids=[], query=nil)
5
- raise "PhraseApp API client can't handle action #{action}" unless api_client.respond_to?(action)
6
-
7
- @api_client = api_client
8
- @action = action
9
- @ids = ids
10
- @query = query
11
- end
12
-
13
- def collection
14
- results = []
15
- page = 1
16
- per_page = 100
17
- paginated, err = send_request(page, per_page)
18
- results << paginated
19
-
20
- while paginated.size == per_page
21
- break if page > 100
22
-
23
- page = page + 1
24
- paginated, err = send_request(page, per_page)
25
- results << paginated if paginated.present?
26
- end
27
-
28
- results.flatten.uniq
29
- end
30
-
31
- private
32
- def send_request(page, per_page)
33
- if @query.present?
34
- @api_client.send(@action, *@ids, page, per_page, @query)
35
- else
36
- @api_client.send(@action, *@ids, page, per_page)
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,59 +0,0 @@
1
- require 'phraseapp-in-context-editor-ruby/api_collection'
2
-
3
- module PhraseApp
4
- module InContextEditor
5
- class ApiWrapper
6
- def initialize
7
- @api_client = PhraseApp::InContextEditor.api_client
8
- end
9
-
10
- def default_locale
11
- @default_locale ||= select_default_locale
12
- end
13
-
14
- def default_translation(key)
15
- params = PhraseApp::RequestParams::TranslationsByKeyParams.new
16
- translations = PhraseApp::InContextEditor::ApiCollection.new(@api_client, "translations_by_key", project_and_key_id(key), params).collection
17
- return unless translations.present?
18
-
19
- translations.select{ |translation| translation.locale["id"] == default_locale.id }
20
- end
21
-
22
- def keys_with_prefix(prefix)
23
- params = PhraseApp::RequestParams::KeysSearchParams.new(q:"#{prefix}*")
24
- keys_list(params)
25
- end
26
-
27
- def keys_by_names(names)
28
- names = names.join(',')
29
- params = PhraseApp::RequestParams::KeysSearchParams.new(:q => "name:#{names}")
30
- keys_list(params)
31
- end
32
-
33
- def keys_list(params)
34
- PhraseApp::InContextEditor::ApiCollection.new(@api_client, "keys_search", project_id, params).collection
35
- end
36
-
37
- def blacklisted_keys
38
- PhraseApp::InContextEditor::ApiCollection.new(@api_client, "blacklisted_keys_list", project_id).collection.map{ |rule| rule.name }
39
- end
40
-
41
- private
42
-
43
- def select_default_locale
44
- locales = PhraseApp::InContextEditor::ApiCollection.new(@api_client, "locales_list", project_id).collection
45
- return unless locales.present?
46
-
47
- locales.select{ |loc| loc.default }.first
48
- end
49
-
50
- def project_id
51
- [PhraseApp::InContextEditor.project_id]
52
- end
53
-
54
- def project_and_key_id(key)
55
- project_id << key.id
56
- end
57
- end
58
- end
59
- end
@@ -1,37 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require 'phraseapp-in-context-editor-ruby'
4
-
5
- module PhraseApp
6
- module InContextEditor
7
- class Cache
8
- attr_accessor :lifetime
9
-
10
- def initialize(args={})
11
- @store = {}
12
- @lifetime = args.fetch(:lifetime, PhraseApp::InContextEditor.cache_lifetime)
13
- end
14
-
15
- def cached?(cache_key)
16
- @store.has_key?(cache_key) && !expired?(cache_key)
17
- end
18
-
19
- def get(cache_key)
20
- begin
21
- @store.fetch(cache_key)[:payload]
22
- rescue
23
- nil
24
- end
25
- end
26
-
27
- def set(cache_key, value)
28
- @store[cache_key] = {timestamp: Time.now, payload: value}
29
- end
30
-
31
- private
32
- def expired?(cache_key)
33
- @store.fetch(cache_key)[:timestamp] < (Time.now - @lifetime)
34
- end
35
- end
36
- end
37
- end
@@ -1,46 +0,0 @@
1
- require 'phraseapp-in-context-editor-ruby/fallback_keys_fetcher'
2
- require 'phraseapp-in-context-editor-ruby/key_names_cache'
3
-
4
- module PhraseApp
5
- module InContextEditor
6
- class DisplayableKeyIdentifier
7
- attr_reader :api_wrapper, :key_names_cache
8
-
9
- def initialize(api_wrapper)
10
- @api_wrapper = api_wrapper
11
- @key_names_cache = KeyNamesCache.new(@api_wrapper)
12
- end
13
-
14
- def identify(key_name, options)
15
- fallback_key_names = FallbackKeysFetcher.extract_fallback_keys(key_name, options)
16
- return key_name if fallback_key_names.empty?
17
-
18
- key_names = [key_name] | fallback_key_names
19
- available_key_names = find_keys_within_phraseapp(key_names)
20
-
21
- key_names.each do |item|
22
- if available_key_names.include?(item)
23
- return item
24
- end
25
- end
26
-
27
- return key_name
28
- end
29
-
30
- private
31
-
32
- def find_keys_within_phraseapp(key_names)
33
- key_names_to_check_against_api = key_names - @key_names_cache.pre_fetched(key_names)
34
- @key_names_cache.pre_cached(key_names) | key_names_returned_from_api_for(key_names_to_check_against_api)
35
- end
36
-
37
- def key_names_returned_from_api_for(key_names)
38
- if key_names.size > 0
39
- api_wrapper.keys_by_names(key_names).map { |key| key.name }
40
- else
41
- []
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,44 +0,0 @@
1
- module PhraseApp
2
- module InContextEditor
3
- class FallbackKeysFetcher
4
-
5
- def self.extract_fallback_keys(key, options)
6
- fallback_items = []
7
- if options.has_key?(:default)
8
- if options[:default].kind_of?(Array)
9
- fallback_items = options[:default]
10
- else
11
- fallback_items << options[:default]
12
- end
13
- end
14
-
15
- return fallback_items.map{ |item| process_fallback_item(item, key, options) }.flatten.uniq
16
- end
17
-
18
- def self.process_fallback_item(item, key, options)
19
- fallback_keys = []
20
- if item.kind_of?(Symbol)
21
- fallback_key_name = item.to_s
22
- if options.has_key?(:scope)
23
- if options[:scope].is_a?(Array)
24
- fallback_key_name = "#{options[:scope].join(".")}.#{item}"
25
- else
26
- fallback_key_name = "#{options[:scope]}.#{item}"
27
- end
28
- end
29
- fallback_keys << fallback_key_name
30
-
31
- if key == "helpers.label.#{fallback_key_name}" # http://apidock.com/rails/v3.1.0/ActionView/Helpers/FormHelper/label
32
- fallback_keys << "activerecord.attributes.#{fallback_key_name}"
33
- end
34
-
35
- if key.start_with?("simple_form.") # special treatment for simple form
36
- fallback_keys << "activerecord.attributes.#{item}"
37
- end
38
- end
39
-
40
- return fallback_keys
41
- end
42
- end
43
- end
44
- end