station 0.0.95 → 0.0.102
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +6 -5
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/bin/nexmo-developer +11 -3
- data/lib/nexmo_developer/.rubocop.yml +3 -0
- data/lib/nexmo_developer/.ruby-version +1 -1
- data/lib/nexmo_developer/Dockerfile +1 -1
- data/lib/nexmo_developer/Gemfile +5 -5
- data/lib/nexmo_developer/Gemfile.lock +18 -18
- data/lib/nexmo_developer/Guardfile +2 -2
- data/lib/nexmo_developer/app/controllers/dashboard_controller.rb +1 -1
- data/lib/nexmo_developer/app/presenters/tutorial_list_item.rb +3 -3
- data/lib/nexmo_developer/app/services/translator/file_translator.rb +18 -12
- data/lib/nexmo_developer/app/services/translator/smartling/api/upload_file.rb +4 -2
- data/lib/nexmo_developer/app/services/translator/translation_request.rb +3 -2
- data/lib/nexmo_developer/app/services/translator/utils.rb +28 -1
- data/lib/nexmo_developer/app/views/contribute/guides/markdown-guide.md +70 -48
- data/lib/nexmo_developer/app/webpacker/javascript/components/feedback/Feedback.vue +1 -0
- data/lib/nexmo_developer/app/webpacker/stylesheets/layout/_api.scss +1 -0
- data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
- data/lib/nexmo_developer/version.rb +1 -1
- data/package.json +13 -13
- data/station.gemspec +4 -4
- data/yarn.lock +340 -266
- metadata +27 -145
- data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css +0 -14950
- data/lib/nexmo_developer/public/packs-test/css/application-5047da33.chunk.css.map +0 -1
- data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css +0 -15085
- data/lib/nexmo_developer/public/packs-test/css/application-a5fa0fdb.chunk.css.map +0 -1
- data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css +0 -13
- data/lib/nexmo_developer/public/packs-test/css/application-f92656e6.chunk.css.map +0 -1
- data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css +0 -13
- data/lib/nexmo_developer/public/packs-test/css/application-f9d1bdbc.chunk.css.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js +0 -59763
- data/lib/nexmo_developer/public/packs-test/js/0-e58f598fb97314a89835.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js +0 -6405
- data/lib/nexmo_developer/public/packs-test/js/application-21483bf220c794127fa9.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js +0 -7839
- data/lib/nexmo_developer/public/packs-test/js/application-6e53f67bc3230c42f9dd.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js +0 -6405
- data/lib/nexmo_developer/public/packs-test/js/application-76d5a80c3775a7e2327a.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js +0 -6619
- data/lib/nexmo_developer/public/packs-test/js/application-c6f3e7a9d98562f76890.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js +0 -6405
- data/lib/nexmo_developer/public/packs-test/js/application-d280e78dd4f9d3d9b466.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js +0 -155
- data/lib/nexmo_developer/public/packs-test/js/runtime~application-1c11a8c601900ade80b6.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js +0 -61849
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-6518249ed8d7aa985a8b.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js +0 -59077
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-bc967911d70f3f4a5151.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js +0 -61843
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-d2bde7a8e622fafdeb1d.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js +0 -62431
- data/lib/nexmo_developer/public/packs-test/js/vendors~application-eb13e7814c54bf76b364.chunk.js.map +0 -1
- data/lib/nexmo_developer/public/packs-test/manifest.json +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 731c9ae04b6db8aabd750d8a19a35f6c7a561fa1ef1dfebeaa4038b182c288f2
|
4
|
+
data.tar.gz: 80ebc07b60b8757bbcca9469fe64d5fdc7c123cf84e20fc9ffedd912570d07de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41c85d4da7b9c1546150b05dcd717a8ce2b5bfc52d92cef4741858d07b58f79995a782aea88e904109b0c5978f390d0962d5789becca2a9cf216e8297f3ead86
|
7
|
+
data.tar.gz: ac8d0143cc76403a1138663d7a3120d0a3b292a7ecfff5aca371d7aef01dc99750961a2786a23deb47f02922c81772cbb53803703d55e5bb868065b6312b7e1f
|
data/Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ruby:2.
|
1
|
+
FROM ruby:2.7.2-alpine AS build-env
|
2
2
|
ARG RAILS_ROOT=/station
|
3
3
|
ARG BUILD_PACKAGES="build-base curl-dev git"
|
4
4
|
ARG DEV_PACKAGES="postgresql-dev yaml-dev zlib-dev nodejs yarn"
|
@@ -19,11 +19,12 @@ COPY lib/nexmo_developer/Gemfile* package.json yarn.lock $RAILS_ROOT/
|
|
19
19
|
RUN bundle config --global frozen 1 \
|
20
20
|
&& gem update --system \
|
21
21
|
&& gem install bundler
|
22
|
+
|
22
23
|
RUN bundle install --without development:test:assets -j4 --retry 3 --path=vendor/bundle \
|
23
24
|
# Remove unneeded files (cached *.gem, *.o, *.c)
|
24
|
-
&& rm -rf vendor/bundle/ruby/2.
|
25
|
-
&& find vendor/bundle/ruby/2.
|
26
|
-
&& find vendor/bundle/ruby/2.
|
25
|
+
&& rm -rf vendor/bundle/ruby/2.7.0/cache/*.gem \
|
26
|
+
&& find vendor/bundle/ruby/2.7.0/gems/ -name "*.c" -delete \
|
27
|
+
&& find vendor/bundle/ruby/2.7.0/gems/ -name "*.o" -delete
|
27
28
|
|
28
29
|
# Install node dependencies
|
29
30
|
RUN yarn install --frozen-lockfile
|
@@ -36,7 +37,7 @@ RUN bundle exec rake assets:precompile
|
|
36
37
|
RUN rm -rf node_modules tmp/cache vendor/assets spec
|
37
38
|
|
38
39
|
################ Build step done ###############
|
39
|
-
FROM ruby:2.
|
40
|
+
FROM ruby:2.7.2-alpine
|
40
41
|
ARG RAILS_ROOT=/station
|
41
42
|
|
42
43
|
ENV RACK_ENV production
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
ruby '2.
|
2
|
+
ruby '2.7.2'
|
data/Gemfile.lock
CHANGED
data/bin/nexmo-developer
CHANGED
@@ -3,6 +3,7 @@ require 'optparse'
|
|
3
3
|
|
4
4
|
clear_cache = false
|
5
5
|
rake_ci = false
|
6
|
+
run_migrations = false
|
6
7
|
rake_smartling_download = false
|
7
8
|
rake_smartling_upload = false
|
8
9
|
|
@@ -26,6 +27,9 @@ docs_path = OptionParser.new do |opts|
|
|
26
27
|
opts.on("--clear-cache", "Clear Rails cache") do
|
27
28
|
clear_cache = true
|
28
29
|
end
|
30
|
+
opts.on("--run-migrations", "Runs db migrations") do
|
31
|
+
run_migrations = true
|
32
|
+
end
|
29
33
|
opts.on("--rake-ci", "Runs ci tasks") do
|
30
34
|
rake_ci = true
|
31
35
|
end
|
@@ -87,23 +91,27 @@ require 'rake'
|
|
87
91
|
require 'config/application'
|
88
92
|
require 'rails/command'
|
89
93
|
|
94
|
+
Rails.application.load_tasks
|
95
|
+
|
90
96
|
if clear_cache
|
91
97
|
puts "Clearing Rails cache..."
|
92
98
|
Rails::Command.invoke 'runner', ['Rails.cache.clear']
|
93
99
|
end
|
94
100
|
|
101
|
+
if run_migrations
|
102
|
+
puts "Running migrations..."
|
103
|
+
Rails::Command.invoke 'runner', ["Rake::Task['db:migrate'].invoke"]
|
104
|
+
end
|
105
|
+
|
95
106
|
if rake_ci
|
96
107
|
puts 'Running Rake tasks...'
|
97
|
-
Rails.application.load_tasks
|
98
108
|
Rails::Command.invoke 'runner', ["Rake::Task['db:setup'].invoke"]
|
99
109
|
Rails::Command.invoke 'runner', ["Rake::Task['ci:all'].invoke"]
|
100
110
|
elsif rake_smartling_download
|
101
111
|
puts 'Running Smartling download check...'
|
102
|
-
Rails.application.load_tasks
|
103
112
|
Rails::Command.invoke 'runner', ["Rake::Task['smartling:download'].invoke"]
|
104
113
|
elsif rake_smartling_upload
|
105
114
|
puts 'Running Smartling upload process...'
|
106
|
-
Rails.application.load_tasks
|
107
115
|
|
108
116
|
frequency, *paths = ARGV
|
109
117
|
Rails::Command.invoke 'runner', ["Rake::Task['smartling:upload'].invoke(#{paths}, #{frequency})"]
|
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.2
|
data/lib/nexmo_developer/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
ruby '2.
|
2
|
+
ruby '2.7.2'
|
3
3
|
|
4
4
|
git_source(:github) do |repo_name|
|
5
5
|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
@@ -74,7 +74,7 @@ gem 'icalendar', require: false
|
|
74
74
|
gem 'neatjson'
|
75
75
|
|
76
76
|
# Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.
|
77
|
-
gem 'faker', '2.
|
77
|
+
gem 'faker', '2.15.1', require: false
|
78
78
|
|
79
79
|
# factory_girl_rails provides integration between factory_girl and rails 3 or newer (currently just automatic factory definition loading)
|
80
80
|
gem 'factory_bot_rails', '6.1.0', require: false
|
@@ -110,7 +110,7 @@ gem 'bootsnap', require: false
|
|
110
110
|
gem 'diffy', require: false
|
111
111
|
|
112
112
|
# Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
|
113
|
-
gem 'rubocop', '~> 1.2
|
113
|
+
gem 'rubocop', '~> 1.4.2', require: false
|
114
114
|
gem 'rubocop-rails', '~> 2.8', require: false
|
115
115
|
|
116
116
|
# Volta needs a CSS autoprefixer
|
@@ -129,9 +129,9 @@ gem 'lograge'
|
|
129
129
|
gem 'countries'
|
130
130
|
gem 'country_select', '~> 4.0'
|
131
131
|
|
132
|
-
gem 'nexmo-oas-renderer', '~> 2.4.
|
132
|
+
gem 'nexmo-oas-renderer', '~> 2.4.1', require: false
|
133
133
|
|
134
|
-
gem 'nexmo_markdown_renderer', '~> 0.
|
134
|
+
gem 'nexmo_markdown_renderer', '~> 0.7'
|
135
135
|
|
136
136
|
gem 'smartling'
|
137
137
|
|
@@ -163,7 +163,7 @@ GEM
|
|
163
163
|
em-websocket (0.5.2)
|
164
164
|
eventmachine (>= 0.12.9)
|
165
165
|
http_parser.rb (~> 0.6.0)
|
166
|
-
erubi (1.
|
166
|
+
erubi (1.10.0)
|
167
167
|
eventmachine (1.2.7)
|
168
168
|
execjs (2.7.0)
|
169
169
|
factory_bot (6.1.0)
|
@@ -171,7 +171,7 @@ GEM
|
|
171
171
|
factory_bot_rails (6.1.0)
|
172
172
|
factory_bot (~> 6.1.0)
|
173
173
|
railties (>= 5.0.0)
|
174
|
-
faker (2.
|
174
|
+
faker (2.15.1)
|
175
175
|
i18n (>= 1.6, < 2)
|
176
176
|
faraday (1.1.0)
|
177
177
|
multipart-post (>= 1.2, < 3)
|
@@ -258,7 +258,7 @@ GEM
|
|
258
258
|
activerecord
|
259
259
|
kaminari-core (= 1.2.1)
|
260
260
|
kaminari-core (1.2.1)
|
261
|
-
listen (3.3.
|
261
|
+
listen (3.3.1)
|
262
262
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
263
263
|
rb-inotify (~> 0.9, >= 0.9.10)
|
264
264
|
lograge (0.11.2)
|
@@ -266,7 +266,7 @@ GEM
|
|
266
266
|
activesupport (>= 4)
|
267
267
|
railties (>= 4)
|
268
268
|
request_store (~> 1.0)
|
269
|
-
loofah (2.
|
269
|
+
loofah (2.8.0)
|
270
270
|
crass (~> 1.0.2)
|
271
271
|
nokogiri (>= 1.5.9)
|
272
272
|
lumberjack (1.2.8)
|
@@ -294,8 +294,8 @@ GEM
|
|
294
294
|
neatjson (0.9)
|
295
295
|
nenv (0.3.0)
|
296
296
|
netrc (0.11.0)
|
297
|
-
newrelic_rpm (6.
|
298
|
-
nexmo-oas-renderer (2.4.
|
297
|
+
newrelic_rpm (6.14.0)
|
298
|
+
nexmo-oas-renderer (2.4.1)
|
299
299
|
activemodel (~> 6.0)
|
300
300
|
activesupport (~> 6.0)
|
301
301
|
banzai (~> 0.1.2)
|
@@ -308,7 +308,7 @@ GEM
|
|
308
308
|
sass (~> 3.1)
|
309
309
|
shotgun (~> 0.9)
|
310
310
|
sinatra (~> 2.0)
|
311
|
-
nexmo_markdown_renderer (0.
|
311
|
+
nexmo_markdown_renderer (0.7.0)
|
312
312
|
activemodel (~> 6.0)
|
313
313
|
banzai (~> 0.1.2)
|
314
314
|
i18n (~> 1.7)
|
@@ -340,7 +340,7 @@ GEM
|
|
340
340
|
sawyer (~> 0.8.0, >= 0.5.3)
|
341
341
|
oj (3.10.15)
|
342
342
|
orm_adapter (0.5.0)
|
343
|
-
parallel (1.
|
343
|
+
parallel (1.20.1)
|
344
344
|
parser (2.7.2.0)
|
345
345
|
ast (~> 2.4.1)
|
346
346
|
pg (1.2.3)
|
@@ -398,7 +398,7 @@ GEM
|
|
398
398
|
recaptcha (5.6.0)
|
399
399
|
json
|
400
400
|
redcarpet (3.4.0)
|
401
|
-
redis (4.2.
|
401
|
+
redis (4.2.5)
|
402
402
|
regexp_parser (1.8.2)
|
403
403
|
request_store (1.5.0)
|
404
404
|
rack (>= 1.4)
|
@@ -437,16 +437,16 @@ GEM
|
|
437
437
|
rspec-snapshot (0.1.2)
|
438
438
|
rspec (> 3.0.0)
|
439
439
|
rspec-support (3.10.0)
|
440
|
-
rubocop (1.2
|
440
|
+
rubocop (1.4.2)
|
441
441
|
parallel (~> 1.10)
|
442
442
|
parser (>= 2.7.1.5)
|
443
443
|
rainbow (>= 2.2.2, < 4.0)
|
444
444
|
regexp_parser (>= 1.8)
|
445
445
|
rexml
|
446
|
-
rubocop-ast (>= 1.
|
446
|
+
rubocop-ast (>= 1.1.1)
|
447
447
|
ruby-progressbar (~> 1.7)
|
448
448
|
unicode-display_width (>= 1.4.0, < 2.0)
|
449
|
-
rubocop-ast (1.
|
449
|
+
rubocop-ast (1.2.0)
|
450
450
|
parser (>= 2.7.1.5)
|
451
451
|
rubocop-rails (2.8.1)
|
452
452
|
activesupport (>= 4.2.0)
|
@@ -529,7 +529,7 @@ GEM
|
|
529
529
|
activemodel (>= 6.0.0)
|
530
530
|
bindex (>= 0.4.0)
|
531
531
|
railties (>= 6.0.0)
|
532
|
-
webmock (3.
|
532
|
+
webmock (3.10.0)
|
533
533
|
addressable (>= 2.3.6)
|
534
534
|
crack (>= 0.3.2)
|
535
535
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -573,7 +573,7 @@ DEPENDENCIES
|
|
573
573
|
diffy
|
574
574
|
dotenv-rails
|
575
575
|
factory_bot_rails (= 6.1.0)
|
576
|
-
faker (= 2.
|
576
|
+
faker (= 2.15.1)
|
577
577
|
ffi (>= 1.9.24)
|
578
578
|
geocoder
|
579
579
|
gmaps4rails
|
@@ -589,8 +589,8 @@ DEPENDENCIES
|
|
589
589
|
lograge
|
590
590
|
neatjson
|
591
591
|
newrelic_rpm
|
592
|
-
nexmo-oas-renderer (~> 2.4.
|
593
|
-
nexmo_markdown_renderer (~> 0.
|
592
|
+
nexmo-oas-renderer (~> 2.4.1)
|
593
|
+
nexmo_markdown_renderer (~> 0.7)
|
594
594
|
nokogiri (~> 1.10.9)
|
595
595
|
octokit
|
596
596
|
pg (~> 1.2)
|
@@ -605,7 +605,7 @@ DEPENDENCIES
|
|
605
605
|
rspec-collection_matchers
|
606
606
|
rspec-rails (~> 4.0)
|
607
607
|
rspec-snapshot (~> 0.1.2)
|
608
|
-
rubocop (~> 1.2
|
608
|
+
rubocop (~> 1.4.2)
|
609
609
|
rubocop-rails (~> 2.8)
|
610
610
|
ruby-progressbar
|
611
611
|
sassc-rails (~> 2.1)
|
@@ -624,7 +624,7 @@ DEPENDENCIES
|
|
624
624
|
woothee
|
625
625
|
|
626
626
|
RUBY VERSION
|
627
|
-
ruby 2.
|
627
|
+
ruby 2.7.2p137
|
628
628
|
|
629
629
|
BUNDLED WITH
|
630
630
|
2.1.4
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# directories %w(app lib config test spec features) \
|
6
6
|
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
7
|
|
8
|
-
##
|
8
|
+
## NOTE: if you are using the `directories` clause above and you are not
|
9
9
|
## watching the project directory ('.'), then you will want to move
|
10
10
|
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
11
|
#
|
@@ -54,7 +54,7 @@ guard 'livereload' do
|
|
54
54
|
watch(%r{config/locales/.+\.yml})
|
55
55
|
end
|
56
56
|
|
57
|
-
#
|
57
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
58
58
|
# rspec may be run, below are examples of the most common uses.
|
59
59
|
# * bundler: 'bundle exec rspec'
|
60
60
|
# * bundler binstubs: 'bin/rspec'
|
@@ -197,7 +197,7 @@ class DashboardController < ApplicationController
|
|
197
197
|
|
198
198
|
parts.insert(1, 'top-level') if parts.count < 3
|
199
199
|
|
200
|
-
parts = [parts[0], parts[1], parts[2
|
200
|
+
parts = [parts[0], parts[1], parts[2..].join('/')] if parts.count > 3
|
201
201
|
next if parts[0] == 'migrate'
|
202
202
|
|
203
203
|
x = @complete_coverage
|
@@ -62,11 +62,11 @@ class TutorialListItem
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def product_url
|
65
|
-
"/#{I18n.locale}/#{products.join
|
65
|
+
"/#{I18n.locale}/#{products.join}/tutorials"
|
66
66
|
end
|
67
67
|
|
68
68
|
def url
|
69
|
-
external_link || "/#{I18n.locale}/#{products.join
|
69
|
+
external_link || "/#{I18n.locale}/#{products.join}/tutorials/#{filename}/#{first_step}"
|
70
70
|
end
|
71
71
|
|
72
72
|
def available_languages
|
@@ -74,7 +74,7 @@ class TutorialListItem
|
|
74
74
|
OpenStruct.new(
|
75
75
|
language: language,
|
76
76
|
label: Nexmo::Markdown::CodeLanguage.find(language).label,
|
77
|
-
url: external_link || "/#{products.join
|
77
|
+
url: external_link || "/#{products.join}/tutorials/#{filename}/#{first_step}/#{language}"
|
78
78
|
)
|
79
79
|
end
|
80
80
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Translator
|
2
2
|
class FileTranslator
|
3
|
+
include Utils
|
4
|
+
|
3
5
|
attr_reader :doc_path
|
4
6
|
|
5
7
|
def initialize(doc_path)
|
@@ -12,41 +14,45 @@ module Translator
|
|
12
14
|
Translator::TranslationRequest.new(
|
13
15
|
locale: locale_with_region(locale),
|
14
16
|
frequency: frequency,
|
15
|
-
file_uri:
|
17
|
+
file_uri: uri,
|
18
|
+
file_path: full_path
|
16
19
|
)
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
24
|
+
def uri
|
25
|
+
@uri ||= file_uri(doc_path)
|
26
|
+
end
|
27
|
+
|
21
28
|
def frontmatter
|
22
29
|
@frontmatter ||= YAML.safe_load(File.read(full_path))
|
23
30
|
end
|
24
31
|
|
25
32
|
def full_path
|
26
|
-
@full_path ||= "#{Rails.configuration.docs_base_path}
|
33
|
+
@full_path ||= "#{Rails.configuration.docs_base_path}/#{doc_path}"
|
27
34
|
end
|
28
35
|
|
29
36
|
def frequency
|
30
37
|
@frequency ||= frontmatter['translation_frequency'] || product_translation_frequency
|
31
38
|
end
|
32
39
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'zh-CN'
|
39
|
-
else
|
40
|
-
locale.to_s
|
40
|
+
def product_from_path
|
41
|
+
@product_from_path ||= begin
|
42
|
+
Pathname.new(
|
43
|
+
doc_path.gsub(%r{(_documentation|_tutorials|_use_cases)/#{I18n.default_locale}/}, '')
|
44
|
+
).dirname.to_s
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def product
|
45
49
|
@product ||= begin
|
46
50
|
products = YAML.safe_load(File.open("#{Rails.configuration.docs_base_path}/config/products.yml"))
|
47
|
-
product = products['products'].detect
|
51
|
+
product = products['products'].detect do |p|
|
52
|
+
product_from_path.starts_with?(p['path']) || frontmatter['products']&.include?(p['path'])
|
53
|
+
end
|
48
54
|
|
49
|
-
raise ArgumentError,
|
55
|
+
raise ArgumentError, "Unable to match document with products list in config/products.yml for #{full_path}" unless product
|
50
56
|
|
51
57
|
product
|
52
58
|
end
|
@@ -53,8 +53,10 @@ module Translator
|
|
53
53
|
def file
|
54
54
|
@file ||= begin
|
55
55
|
file = Tempfile.new
|
56
|
-
file.write
|
57
|
-
|
56
|
+
file.write(
|
57
|
+
Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
|
58
|
+
File.read(@translation_request.file_path)
|
59
|
+
)
|
58
60
|
)
|
59
61
|
file.rewind
|
60
62
|
file.close
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Translator
|
2
2
|
class TranslationRequest
|
3
|
-
attr_reader :locale, :frequency, :file_uri
|
3
|
+
attr_reader :locale, :frequency, :file_uri, :file_path
|
4
4
|
|
5
|
-
def initialize(locale:, frequency:, file_uri:)
|
5
|
+
def initialize(locale:, frequency:, file_uri:, file_path:)
|
6
6
|
@locale = locale
|
7
7
|
@frequency = frequency
|
8
8
|
@file_uri = file_uri
|
9
|
+
@file_path = file_path
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -11,12 +11,33 @@ module Translator
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def locale_with_region(locale)
|
15
|
+
case locale.to_s
|
16
|
+
when 'ja', 'ja-JP'
|
17
|
+
'ja-JP'
|
18
|
+
when 'cn', 'zh-CN'
|
19
|
+
'zh-CN'
|
20
|
+
else
|
21
|
+
locale.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
14
25
|
def storage_folder(filename, locale)
|
15
26
|
if filename.starts_with? '_documentation'
|
16
27
|
dir_path = Pathname.new(file_uri(filename)).dirname.to_s
|
17
28
|
"#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
|
29
|
+
elsif filename.starts_with? '_use_cases'
|
30
|
+
"#{Rails.configuration.docs_base_path}/_use_cases/#{locale}"
|
18
31
|
elsif filename.starts_with? 'config/locales'
|
19
32
|
Pathname.new(file_uri(filename)).dirname.to_s
|
33
|
+
elsif filename.starts_with? 'config/tutorials'
|
34
|
+
pathname = Pathname.new(filename.gsub("config/tutorials/#{I18n.default_locale}/", ''))
|
35
|
+
dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
|
36
|
+
"#{Rails.configuration.docs_base_path}/config/tutorials/#{locale}#{dir_path}"
|
37
|
+
elsif filename.starts_with? '_tutorials'
|
38
|
+
pathname = Pathname.new(filename.gsub("_tutorials/#{I18n.default_locale}/", ''))
|
39
|
+
dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
|
40
|
+
"#{Rails.configuration.docs_base_path}/_tutorials/#{locale}#{dir_path}"
|
20
41
|
else
|
21
42
|
dir_path = Pathname.new(file_uri(filename)).dirname.to_s
|
22
43
|
"#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
|
@@ -36,7 +57,13 @@ module Translator
|
|
36
57
|
end
|
37
58
|
|
38
59
|
def file_uri(filename)
|
39
|
-
filename.
|
60
|
+
if filename.starts_with? '_documentation'
|
61
|
+
filename.gsub(%r{_documentation/[a-z]{2}/}, '')
|
62
|
+
else
|
63
|
+
filename.gsub(%r{(_use_cases|_tutorials|config/tutorials)/#{I18n.default_locale}/(.*)}) do |_|
|
64
|
+
"#{$1}/#{$2}"
|
65
|
+
end
|
66
|
+
end
|
40
67
|
end
|
41
68
|
end
|
42
69
|
end
|