wovnrb 2.2.3 → 3.0.1
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/.rubocop_todo.yml +5 -0
- data/README.en.md +198 -0
- data/README.ja.md +180 -0
- data/README.md +1 -0
- data/docker/docker-compose.yml +11 -0
- data/docker/rails/Dockerfile +6 -0
- data/docker/rails/TestSite/.browserslistrc +1 -0
- data/docker/rails/TestSite/.gitignore +63 -0
- data/docker/rails/TestSite/Gemfile +56 -0
- data/docker/rails/TestSite/README.md +24 -0
- data/docker/rails/TestSite/Rakefile +6 -0
- data/docker/rails/TestSite/app/assets/config/manifest.js +2 -0
- data/docker/rails/TestSite/app/assets/images/.keep +0 -0
- data/docker/rails/TestSite/app/assets/stylesheets/application.css +15 -0
- data/docker/rails/TestSite/app/assets/stylesheets/redirects.scss +3 -0
- data/docker/rails/TestSite/app/channels/application_cable/channel.rb +4 -0
- data/docker/rails/TestSite/app/channels/application_cable/connection.rb +4 -0
- data/docker/rails/TestSite/app/controllers/application_controller.rb +2 -0
- data/docker/rails/TestSite/app/controllers/concerns/.keep +0 -0
- data/docker/rails/TestSite/app/controllers/pages_controller.rb +7 -0
- data/docker/rails/TestSite/app/controllers/redirects_controller.rb +5 -0
- data/docker/rails/TestSite/app/helpers/application_helper.rb +2 -0
- data/docker/rails/TestSite/app/helpers/pages_helper.rb +2 -0
- data/docker/rails/TestSite/app/helpers/redirects_helper.rb +2 -0
- data/docker/rails/TestSite/app/javascript/channels/consumer.js +6 -0
- data/docker/rails/TestSite/app/javascript/channels/index.js +5 -0
- data/docker/rails/TestSite/app/javascript/packs/application.js +17 -0
- data/docker/rails/TestSite/app/jobs/application_job.rb +7 -0
- data/docker/rails/TestSite/app/mailers/application_mailer.rb +4 -0
- data/docker/rails/TestSite/app/models/application_record.rb +3 -0
- data/docker/rails/TestSite/app/models/concerns/.keep +0 -0
- data/docker/rails/TestSite/app/views/layouts/application.html.erb +15 -0
- data/docker/rails/TestSite/app/views/layouts/mailer.html.erb +13 -0
- data/docker/rails/TestSite/app/views/layouts/mailer.text.erb +1 -0
- data/docker/rails/TestSite/babel.config.js +72 -0
- data/docker/rails/TestSite/bin/bundle +114 -0
- data/docker/rails/TestSite/bin/rails +4 -0
- data/docker/rails/TestSite/bin/rake +4 -0
- data/docker/rails/TestSite/bin/setup +36 -0
- data/docker/rails/TestSite/bin/webpack +18 -0
- data/docker/rails/TestSite/bin/webpack-dev-server +18 -0
- data/docker/rails/TestSite/bin/yarn +11 -0
- data/docker/rails/TestSite/config.ru +5 -0
- data/docker/rails/TestSite/config/application.rb +26 -0
- data/docker/rails/TestSite/config/boot.rb +4 -0
- data/docker/rails/TestSite/config/cable.yml +10 -0
- data/docker/rails/TestSite/config/credentials.yml.enc +1 -0
- data/docker/rails/TestSite/config/database.yml +25 -0
- data/docker/rails/TestSite/config/environment.rb +5 -0
- data/docker/rails/TestSite/config/environments/development.rb +62 -0
- data/docker/rails/TestSite/config/environments/production.rb +112 -0
- data/docker/rails/TestSite/config/environments/test.rb +49 -0
- data/docker/rails/TestSite/config/initializers/application_controller_renderer.rb +8 -0
- data/docker/rails/TestSite/config/initializers/assets.rb +14 -0
- data/docker/rails/TestSite/config/initializers/backtrace_silencers.rb +7 -0
- data/docker/rails/TestSite/config/initializers/content_security_policy.rb +30 -0
- data/docker/rails/TestSite/config/initializers/cookies_serializer.rb +5 -0
- data/docker/rails/TestSite/config/initializers/filter_parameter_logging.rb +4 -0
- data/docker/rails/TestSite/config/initializers/inflections.rb +16 -0
- data/docker/rails/TestSite/config/initializers/mime_types.rb +4 -0
- data/docker/rails/TestSite/config/initializers/wrap_parameters.rb +14 -0
- data/docker/rails/TestSite/config/locales/en.yml +33 -0
- data/docker/rails/TestSite/config/puma.rb +38 -0
- data/docker/rails/TestSite/config/routes.rb +4 -0
- data/docker/rails/TestSite/config/spring.rb +6 -0
- data/docker/rails/TestSite/config/storage.yml +34 -0
- data/docker/rails/TestSite/config/webpack/development.js +5 -0
- data/docker/rails/TestSite/config/webpack/environment.js +3 -0
- data/docker/rails/TestSite/config/webpack/production.js +5 -0
- data/docker/rails/TestSite/config/webpack/test.js +5 -0
- data/docker/rails/TestSite/config/webpacker.yml +96 -0
- data/docker/rails/TestSite/db/seeds.rb +7 -0
- data/docker/rails/TestSite/lib/assets/.keep +0 -0
- data/docker/rails/TestSite/lib/tasks/.keep +0 -0
- data/docker/rails/TestSite/log/.keep +0 -0
- data/docker/rails/TestSite/package.json +15 -0
- data/docker/rails/TestSite/postcss.config.js +12 -0
- data/docker/rails/TestSite/public/index.html +9 -0
- data/docker/rails/TestSite/public/page.html +13 -0
- data/docker/rails/TestSite/public/pages/files/plaintext_unicode.txt +204 -0
- data/docker/rails/TestSite/public/pages/files/simple_css.css +8 -0
- data/docker/rails/TestSite/public/pages/files/simple_javascript.js +2 -0
- data/docker/rails/TestSite/public/pages/html5test.html +555 -0
- data/docker/rails/TestSite/public/pages/oldhtml.html +335 -0
- data/docker/rails/TestSite/public/pages/xhtml.xhtml +726 -0
- data/docker/rails/TestSite/public/redirection_target.html +10 -0
- data/docker/rails/TestSite/public/testdir/testpage-dir.html +9 -0
- data/docker/rails/TestSite/public/testdir/testpage-redirect-destination.html +9 -0
- data/docker/rails/TestSite/public/testpage.html +9 -0
- data/docker/rails/TestSite/public/wovn_index.html +24 -0
- data/docker/rails/TestSite/start.sh +13 -0
- data/docker/rails/TestSite/storage/.keep +0 -0
- data/docker/rails/TestSite/test/application_system_test_case.rb +5 -0
- data/docker/rails/TestSite/test/channels/application_cable/connection_test.rb +11 -0
- data/docker/rails/TestSite/test/controllers/.keep +0 -0
- data/docker/rails/TestSite/test/controllers/pages_controller_test.rb +7 -0
- data/docker/rails/TestSite/test/controllers/redirects_controller_test.rb +7 -0
- data/docker/rails/TestSite/test/fixtures/.keep +0 -0
- data/docker/rails/TestSite/test/fixtures/files/.keep +0 -0
- data/docker/rails/TestSite/test/helpers/.keep +0 -0
- data/docker/rails/TestSite/test/integration/.keep +0 -0
- data/docker/rails/TestSite/test/mailers/.keep +0 -0
- data/docker/rails/TestSite/test/models/.keep +0 -0
- data/docker/rails/TestSite/test/system/.keep +0 -0
- data/docker/rails/TestSite/test/test_helper.rb +13 -0
- data/docker/rails/TestSite/yarn.lock +7642 -0
- data/lib/wovnrb.rb +1 -1
- data/lib/wovnrb/api_translator.rb +1 -1
- data/lib/wovnrb/headers.rb +1 -23
- data/lib/wovnrb/lang.rb +77 -40
- data/lib/wovnrb/railtie.rb +1 -15
- data/lib/wovnrb/services/html_converter.rb +9 -10
- data/lib/wovnrb/store.rb +3 -3
- data/lib/wovnrb/version.rb +1 -1
- data/makefile +16 -0
- data/test/lib/headers_test.rb +7 -25
- data/test/lib/lang_test.rb +10 -40
- data/test/lib/services/html_converter_test.rb +39 -17
- data/test/lib/store_test.rb +2 -1
- data/wovnrb.gemspec +3 -3
- metadata +114 -11
- data/README.md +0 -182
@@ -6,7 +6,7 @@ module Wovnrb
|
|
6
6
|
converter = prepare_html_converter('<html><body><a class="test">hello</a></body></html>', supported_langs: %w[en vi])
|
7
7
|
converted_html, = converter.build_api_compatible_html
|
8
8
|
|
9
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a class=\"test\">hello</a></body></html>"
|
9
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a class=\"test\">hello</a></body></html>"
|
10
10
|
assert_equal(expected_html, converted_html)
|
11
11
|
end
|
12
12
|
|
@@ -19,7 +19,7 @@ module Wovnrb
|
|
19
19
|
converter = prepare_html_converter('<html><body><a class="test">hello</a></body></html>', settings)
|
20
20
|
converted_html, = converter.build_api_compatible_html
|
21
21
|
|
22
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=lang&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?lang=vi\"></head><body><a class=\"test\">hello</a></body></html>"
|
22
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=lang&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?lang=vi\"></head><body><a class=\"test\">hello</a></body></html>"
|
23
23
|
assert_equal(expected_html, converted_html)
|
24
24
|
end
|
25
25
|
|
@@ -28,7 +28,7 @@ module Wovnrb
|
|
28
28
|
converter = prepare_html_converter('<html><body><p>' + long_string + '</p></body></html>', supported_langs: %w[en vi])
|
29
29
|
converted_html, = converter.build_api_compatible_html
|
30
30
|
|
31
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>" + long_string + '</p></body></html>'
|
31
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>" + long_string + '</p></body></html>'
|
32
32
|
assert_equal(expected_html, converted_html)
|
33
33
|
end
|
34
34
|
|
@@ -36,6 +36,7 @@ module Wovnrb
|
|
36
36
|
html = [
|
37
37
|
'<html><body>',
|
38
38
|
'<p>Hello <span wovn-ignore>WOVN</span><p>',
|
39
|
+
'<p>Hello <span data-wovn-ignore>WOVN</span><p>',
|
39
40
|
'<div><span class="ignore-me">should be ignored</span></div>',
|
40
41
|
'<span>Have a nice day!</span>',
|
41
42
|
'</body></html>'
|
@@ -44,7 +45,7 @@ module Wovnrb
|
|
44
45
|
converter = prepare_html_converter(html, ignore_class: ['ignore-me'])
|
45
46
|
converted_html, = converter.build_api_compatible_html
|
46
47
|
|
47
|
-
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>Hello <span wovn-ignore=\"\"><!-- __wovn-backend-ignored-key-0 --></span></p><p></p><div><span class=\"ignore-me\"><!-- __wovn-backend-ignored-key-
|
48
|
+
expected_convert_html = "<html lang=\"en\"><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>Hello <span wovn-ignore=\"\"><!-- __wovn-backend-ignored-key-0 --></span></p><p></p><p>Hello <span data-wovn-ignore=\"\"><!-- __wovn-backend-ignored-key-1 --></span></p><p></p><div><span class=\"ignore-me\"><!-- __wovn-backend-ignored-key-2 --></span></div><span>Have a nice day!</span></body></html>"
|
48
49
|
assert_equal(expected_convert_html, converted_html)
|
49
50
|
end
|
50
51
|
|
@@ -61,7 +62,7 @@ module Wovnrb
|
|
61
62
|
converter = prepare_html_converter(html, ignore_class: [])
|
62
63
|
converted_html, = converter.build_api_compatible_html
|
63
64
|
|
64
|
-
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><form action=\"/test\" method=\"POST\"><!-- __wovn-backend-ignored-key-0 --></form></body></html>"
|
65
|
+
expected_convert_html = "<html lang=\"en\"><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><form action=\"/test\" method=\"POST\"><!-- __wovn-backend-ignored-key-0 --></form></body></html>"
|
65
66
|
assert_equal(expected_convert_html, converted_html)
|
66
67
|
end
|
67
68
|
|
@@ -79,7 +80,7 @@ module Wovnrb
|
|
79
80
|
converted_html, = converter.build_api_compatible_html
|
80
81
|
|
81
82
|
expected_convert_html = [
|
82
|
-
'<html><head>',
|
83
|
+
'<html lang="en"><head>',
|
83
84
|
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body>",
|
84
85
|
'<input id="user-id" type="hidden" value="__wovn-backend-ignored-key-0">',
|
85
86
|
'<input id="password" type="hidden" value="__wovn-backend-ignored-key-1">',
|
@@ -94,7 +95,7 @@ module Wovnrb
|
|
94
95
|
converter = prepare_html_converter('<html><body><a>hello</a></body></html>', supported_langs: %w[en vi])
|
95
96
|
translated_html = converter.build
|
96
97
|
|
97
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
98
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
98
99
|
assert_equal(expected_html, translated_html)
|
99
100
|
end
|
100
101
|
|
@@ -102,7 +103,7 @@ module Wovnrb
|
|
102
103
|
converter = prepare_html_converter('<html><body><a>hello</a></body></html>', supported_langs: [])
|
103
104
|
translated_html = converter.build
|
104
105
|
|
105
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body><a>hello</a></body></html>"
|
106
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body><a>hello</a></body></html>"
|
106
107
|
assert_equal(expected_html, translated_html)
|
107
108
|
end
|
108
109
|
|
@@ -110,7 +111,7 @@ module Wovnrb
|
|
110
111
|
converter = prepare_html_converter('<html><head><title>TITLE</title></head><body><a>hello</a></body></html>', supported_langs: %w[en vi])
|
111
112
|
translated_html = converter.build
|
112
113
|
|
113
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><title>TITLE</title><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
114
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><title>TITLE</title><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
114
115
|
assert_equal(expected_html, translated_html)
|
115
116
|
end
|
116
117
|
|
@@ -118,7 +119,7 @@ module Wovnrb
|
|
118
119
|
converter = prepare_html_converter('<html>hello<a>world</a></html>', supported_langs: [])
|
119
120
|
translated_html = converter.build
|
120
121
|
|
121
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body>hello<a>world</a></body></html>"
|
122
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body>hello<a>world</a></body></html>"
|
122
123
|
assert_equal(expected_html, translated_html)
|
123
124
|
end
|
124
125
|
|
@@ -133,7 +134,7 @@ module Wovnrb
|
|
133
134
|
converter = HtmlConverter.new(dom, store, headers)
|
134
135
|
translated_html = converter.build
|
135
136
|
|
136
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body>hello<a>world</a></body></html>"
|
137
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body>hello<a>world</a></body></html>"
|
137
138
|
assert_equal(expected_html, translated_html)
|
138
139
|
end
|
139
140
|
|
@@ -148,16 +149,22 @@ module Wovnrb
|
|
148
149
|
converter = HtmlConverter.new(dom, store, headers)
|
149
150
|
translated_html = converter.build
|
150
151
|
|
151
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=path&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/ja/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/vi/\"></head><body>hello<a>world</a></body></html>"
|
152
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=path&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/ja/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/vi/\"></head><body>hello<a>world</a></body></html>"
|
152
153
|
assert_equal(expected_html, translated_html)
|
153
154
|
end
|
154
155
|
|
155
156
|
def test_replace_snippet
|
156
|
-
converter = prepare_html_converter('<html><head
|
157
|
+
converter = prepare_html_converter('<html><head>
|
158
|
+
<script src="/a"></script>
|
159
|
+
<script src="//j.wovn.io/1" async="true">
|
160
|
+
<script src="//j.wovn.io/1" data-wovnio="key=2wpv0n" async></script>
|
161
|
+
<script src="https//cdn.wovn.io/" data-wovnio="key=2wpv0n async></script>
|
162
|
+
<script src="https://wovn.global.ssl.fastly.net/widget/abcdef></script>
|
163
|
+
</head></html>')
|
157
164
|
converter.send(:replace_snippet)
|
158
165
|
|
159
166
|
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><script src=\"/a\"></script></head><body></body></html>"
|
160
|
-
assert_equal(expected_html, converter.send(:html))
|
167
|
+
assert_equal(expected_html.gsub(/\s+/, ''), converter.send(:html).gsub(/\s+/, ''))
|
161
168
|
end
|
162
169
|
|
163
170
|
def test_replace_hreflangs
|
@@ -168,18 +175,33 @@ module Wovnrb
|
|
168
175
|
assert_equal(expected_html, converter.send(:html))
|
169
176
|
end
|
170
177
|
|
171
|
-
def
|
178
|
+
def test_inject_lang_html_tag_with_no_lang_in_html_tag
|
172
179
|
settings = default_store_settings
|
173
180
|
store = Wovnrb::Store.instance
|
174
181
|
store.update_settings(settings)
|
175
182
|
|
176
183
|
headers = Wovnrb::Headers.new(
|
177
|
-
Wovnrb.get_env('url' => 'http://my-site.com
|
184
|
+
Wovnrb.get_env('url' => 'http://my-site.com/'),
|
178
185
|
Wovnrb.get_settings(settings)
|
179
186
|
)
|
180
187
|
converter = HtmlConverter.new(get_dom('<html><body>hello</body></html>'), store, headers)
|
181
188
|
converter.send(:inject_lang_html_tag)
|
182
|
-
expected_html = '<html lang="
|
189
|
+
expected_html = '<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>hello</body></html>'
|
190
|
+
assert_equal(expected_html, converter.send(:html))
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_inject_lang_html_tag_with_lang_in_html_tag
|
194
|
+
settings = default_store_settings
|
195
|
+
store = Wovnrb::Store.instance
|
196
|
+
store.update_settings(settings)
|
197
|
+
|
198
|
+
headers = Wovnrb::Headers.new(
|
199
|
+
Wovnrb.get_env('url' => 'http://my-site.com/'),
|
200
|
+
Wovnrb.get_settings(settings)
|
201
|
+
)
|
202
|
+
converter = HtmlConverter.new(get_dom('<html lang="th"><body>hello</body></html>'), store, headers)
|
203
|
+
converter.send(:inject_lang_html_tag)
|
204
|
+
expected_html = '<html lang="th"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>hello</body></html>'
|
183
205
|
assert_equal(expected_html, converter.send(:html))
|
184
206
|
end
|
185
207
|
|
data/test/lib/store_test.rb
CHANGED
@@ -132,7 +132,8 @@ module Wovnrb
|
|
132
132
|
store.update_settings('wovn_dev_mode' => true)
|
133
133
|
|
134
134
|
assert(store.dev_mode?)
|
135
|
-
assert_equal('
|
135
|
+
assert_equal('dev-wovn.io', store.wovn_host)
|
136
|
+
assert_equal('http://dev-wovn.io:3001', store.settings['api_url'])
|
136
137
|
assert_equal(3, store.settings['api_timeout_seconds'])
|
137
138
|
end
|
138
139
|
|
data/wovnrb.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'wovnrb/version'
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'wovnrb'
|
7
7
|
spec.version = Wovnrb::VERSION
|
8
|
-
spec.authors = ['
|
9
|
-
spec.email = ['
|
8
|
+
spec.authors = ['Wovn Technologies, Inc.']
|
9
|
+
spec.email = ['dev@wovn.io']
|
10
10
|
spec.summary = 'Gem for WOVN.io'
|
11
11
|
spec.description = 'Ruby gem for WOVN backend on Rack.'
|
12
|
-
spec.homepage = ''
|
12
|
+
spec.homepage = 'https://wovn.io'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
15
|
files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wovnrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
|
9
|
-
autorequire:
|
7
|
+
- Wovn Technologies, Inc.
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
@@ -397,7 +396,7 @@ dependencies:
|
|
397
396
|
version: 2.3.2
|
398
397
|
description: Ruby gem for WOVN backend on Rack.
|
399
398
|
email:
|
400
|
-
-
|
399
|
+
- dev@wovn.io
|
401
400
|
executables: []
|
402
401
|
extensions: []
|
403
402
|
extra_rdoc_files: []
|
@@ -410,8 +409,112 @@ files:
|
|
410
409
|
- Gemfile
|
411
410
|
- LICENSE.txt
|
412
411
|
- PULL_REQUEST_TEMPLATE
|
412
|
+
- README.en.md
|
413
|
+
- README.ja.md
|
413
414
|
- README.md
|
414
415
|
- Rakefile
|
416
|
+
- docker/docker-compose.yml
|
417
|
+
- docker/rails/Dockerfile
|
418
|
+
- docker/rails/TestSite/.browserslistrc
|
419
|
+
- docker/rails/TestSite/.gitignore
|
420
|
+
- docker/rails/TestSite/Gemfile
|
421
|
+
- docker/rails/TestSite/README.md
|
422
|
+
- docker/rails/TestSite/Rakefile
|
423
|
+
- docker/rails/TestSite/app/assets/config/manifest.js
|
424
|
+
- docker/rails/TestSite/app/assets/images/.keep
|
425
|
+
- docker/rails/TestSite/app/assets/stylesheets/application.css
|
426
|
+
- docker/rails/TestSite/app/assets/stylesheets/redirects.scss
|
427
|
+
- docker/rails/TestSite/app/channels/application_cable/channel.rb
|
428
|
+
- docker/rails/TestSite/app/channels/application_cable/connection.rb
|
429
|
+
- docker/rails/TestSite/app/controllers/application_controller.rb
|
430
|
+
- docker/rails/TestSite/app/controllers/concerns/.keep
|
431
|
+
- docker/rails/TestSite/app/controllers/pages_controller.rb
|
432
|
+
- docker/rails/TestSite/app/controllers/redirects_controller.rb
|
433
|
+
- docker/rails/TestSite/app/helpers/application_helper.rb
|
434
|
+
- docker/rails/TestSite/app/helpers/pages_helper.rb
|
435
|
+
- docker/rails/TestSite/app/helpers/redirects_helper.rb
|
436
|
+
- docker/rails/TestSite/app/javascript/channels/consumer.js
|
437
|
+
- docker/rails/TestSite/app/javascript/channels/index.js
|
438
|
+
- docker/rails/TestSite/app/javascript/packs/application.js
|
439
|
+
- docker/rails/TestSite/app/jobs/application_job.rb
|
440
|
+
- docker/rails/TestSite/app/mailers/application_mailer.rb
|
441
|
+
- docker/rails/TestSite/app/models/application_record.rb
|
442
|
+
- docker/rails/TestSite/app/models/concerns/.keep
|
443
|
+
- docker/rails/TestSite/app/views/layouts/application.html.erb
|
444
|
+
- docker/rails/TestSite/app/views/layouts/mailer.html.erb
|
445
|
+
- docker/rails/TestSite/app/views/layouts/mailer.text.erb
|
446
|
+
- docker/rails/TestSite/babel.config.js
|
447
|
+
- docker/rails/TestSite/bin/bundle
|
448
|
+
- docker/rails/TestSite/bin/rails
|
449
|
+
- docker/rails/TestSite/bin/rake
|
450
|
+
- docker/rails/TestSite/bin/setup
|
451
|
+
- docker/rails/TestSite/bin/webpack
|
452
|
+
- docker/rails/TestSite/bin/webpack-dev-server
|
453
|
+
- docker/rails/TestSite/bin/yarn
|
454
|
+
- docker/rails/TestSite/config.ru
|
455
|
+
- docker/rails/TestSite/config/application.rb
|
456
|
+
- docker/rails/TestSite/config/boot.rb
|
457
|
+
- docker/rails/TestSite/config/cable.yml
|
458
|
+
- docker/rails/TestSite/config/credentials.yml.enc
|
459
|
+
- docker/rails/TestSite/config/database.yml
|
460
|
+
- docker/rails/TestSite/config/environment.rb
|
461
|
+
- docker/rails/TestSite/config/environments/development.rb
|
462
|
+
- docker/rails/TestSite/config/environments/production.rb
|
463
|
+
- docker/rails/TestSite/config/environments/test.rb
|
464
|
+
- docker/rails/TestSite/config/initializers/application_controller_renderer.rb
|
465
|
+
- docker/rails/TestSite/config/initializers/assets.rb
|
466
|
+
- docker/rails/TestSite/config/initializers/backtrace_silencers.rb
|
467
|
+
- docker/rails/TestSite/config/initializers/content_security_policy.rb
|
468
|
+
- docker/rails/TestSite/config/initializers/cookies_serializer.rb
|
469
|
+
- docker/rails/TestSite/config/initializers/filter_parameter_logging.rb
|
470
|
+
- docker/rails/TestSite/config/initializers/inflections.rb
|
471
|
+
- docker/rails/TestSite/config/initializers/mime_types.rb
|
472
|
+
- docker/rails/TestSite/config/initializers/wrap_parameters.rb
|
473
|
+
- docker/rails/TestSite/config/locales/en.yml
|
474
|
+
- docker/rails/TestSite/config/puma.rb
|
475
|
+
- docker/rails/TestSite/config/routes.rb
|
476
|
+
- docker/rails/TestSite/config/spring.rb
|
477
|
+
- docker/rails/TestSite/config/storage.yml
|
478
|
+
- docker/rails/TestSite/config/webpack/development.js
|
479
|
+
- docker/rails/TestSite/config/webpack/environment.js
|
480
|
+
- docker/rails/TestSite/config/webpack/production.js
|
481
|
+
- docker/rails/TestSite/config/webpack/test.js
|
482
|
+
- docker/rails/TestSite/config/webpacker.yml
|
483
|
+
- docker/rails/TestSite/db/seeds.rb
|
484
|
+
- docker/rails/TestSite/lib/assets/.keep
|
485
|
+
- docker/rails/TestSite/lib/tasks/.keep
|
486
|
+
- docker/rails/TestSite/log/.keep
|
487
|
+
- docker/rails/TestSite/package.json
|
488
|
+
- docker/rails/TestSite/postcss.config.js
|
489
|
+
- docker/rails/TestSite/public/index.html
|
490
|
+
- docker/rails/TestSite/public/page.html
|
491
|
+
- docker/rails/TestSite/public/pages/files/plaintext_unicode.txt
|
492
|
+
- docker/rails/TestSite/public/pages/files/simple_css.css
|
493
|
+
- docker/rails/TestSite/public/pages/files/simple_javascript.js
|
494
|
+
- docker/rails/TestSite/public/pages/html5test.html
|
495
|
+
- docker/rails/TestSite/public/pages/oldhtml.html
|
496
|
+
- docker/rails/TestSite/public/pages/xhtml.xhtml
|
497
|
+
- docker/rails/TestSite/public/redirection_target.html
|
498
|
+
- docker/rails/TestSite/public/testdir/testpage-dir.html
|
499
|
+
- docker/rails/TestSite/public/testdir/testpage-redirect-destination.html
|
500
|
+
- docker/rails/TestSite/public/testpage.html
|
501
|
+
- docker/rails/TestSite/public/wovn_index.html
|
502
|
+
- docker/rails/TestSite/start.sh
|
503
|
+
- docker/rails/TestSite/storage/.keep
|
504
|
+
- docker/rails/TestSite/test/application_system_test_case.rb
|
505
|
+
- docker/rails/TestSite/test/channels/application_cable/connection_test.rb
|
506
|
+
- docker/rails/TestSite/test/controllers/.keep
|
507
|
+
- docker/rails/TestSite/test/controllers/pages_controller_test.rb
|
508
|
+
- docker/rails/TestSite/test/controllers/redirects_controller_test.rb
|
509
|
+
- docker/rails/TestSite/test/fixtures/.keep
|
510
|
+
- docker/rails/TestSite/test/fixtures/files/.keep
|
511
|
+
- docker/rails/TestSite/test/helpers/.keep
|
512
|
+
- docker/rails/TestSite/test/integration/.keep
|
513
|
+
- docker/rails/TestSite/test/mailers/.keep
|
514
|
+
- docker/rails/TestSite/test/models/.keep
|
515
|
+
- docker/rails/TestSite/test/system/.keep
|
516
|
+
- docker/rails/TestSite/test/test_helper.rb
|
517
|
+
- docker/rails/TestSite/yarn.lock
|
415
518
|
- lib/wovnrb.rb
|
416
519
|
- lib/wovnrb/api_translator.rb
|
417
520
|
- lib/wovnrb/headers.rb
|
@@ -427,6 +530,7 @@ files:
|
|
427
530
|
- lib/wovnrb/text_caches/cache_base.rb
|
428
531
|
- lib/wovnrb/text_caches/memory_cache.rb
|
429
532
|
- lib/wovnrb/version.rb
|
533
|
+
- makefile
|
430
534
|
- test/fixtures/html/test.html
|
431
535
|
- test/fixtures/html/test_translated.html
|
432
536
|
- test/lib/api_translator_test.rb
|
@@ -442,11 +546,11 @@ files:
|
|
442
546
|
- test/lib/wovnrb_test.rb
|
443
547
|
- test/test_helper.rb
|
444
548
|
- wovnrb.gemspec
|
445
|
-
homepage:
|
549
|
+
homepage: https://wovn.io
|
446
550
|
licenses:
|
447
551
|
- MIT
|
448
552
|
metadata: {}
|
449
|
-
post_install_message:
|
553
|
+
post_install_message:
|
450
554
|
rdoc_options: []
|
451
555
|
require_paths:
|
452
556
|
- lib
|
@@ -461,9 +565,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
461
565
|
- !ruby/object:Gem::Version
|
462
566
|
version: '0'
|
463
567
|
requirements: []
|
464
|
-
|
465
|
-
|
466
|
-
signing_key:
|
568
|
+
rubygems_version: 3.0.3
|
569
|
+
signing_key:
|
467
570
|
specification_version: 4
|
468
571
|
summary: Gem for WOVN.io
|
469
572
|
test_files:
|
data/README.md
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
# WOVN.io Ruby Library
|
2
|
-
|
3
|
-
The WOVN.io Ruby library is a library that uses WOVN.io in order to provide translations. The WOVN.io Ruby Library is packaged as Rack Middleware.
|
4
|
-
|
5
|
-
This document explains the process of installing WOVN.io Ruby, as well as set up and configuration process.
|
6
|
-
|
7
|
-
## 1. Install
|
8
|
-
|
9
|
-
### 1.1. Creating a WOVN.io account.
|
10
|
-
|
11
|
-
In order to use the WOVN.io Ruby Library, you need a WOVN.io account. If you do not have an account, please first sign up for one at WOVN.io.
|
12
|
-
|
13
|
-
### 1.2. Adding a Page
|
14
|
-
|
15
|
-
After logging into WOVN.io, add a page that you would like translated.
|
16
|
-
|
17
|
-
### 1.3. Ruby Application Settings
|
18
|
-
|
19
|
-
To use the WOVN.io Ruby Library, insert the following line into your Ruby Application's Gemfile. WOVN.io currently supports version 2.0.1 and up.
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
gem 'wovnrb', '>= 2.0.1'
|
23
|
-
```
|
24
|
-
|
25
|
-
After setting the above, execute the following command to install the WOVN.io Ruby Library.
|
26
|
-
|
27
|
-
```bash
|
28
|
-
bundle install
|
29
|
-
```
|
30
|
-
|
31
|
-
After installing the library, insert the following into your Ruby Application's settings file.
|
32
|
-
|
33
|
-
* If you're using Ruby on Rails
|
34
|
-
|
35
|
-
Insert the following into either config/application.rb or config/environments/.
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
...
|
39
|
-
|
40
|
-
config.wovnrb = {
|
41
|
-
:project_token => 'EnS!t3',
|
42
|
-
:default_lang => 'en',
|
43
|
-
:supported_langs => ['en'],
|
44
|
-
:url_pattern => 'path'
|
45
|
-
}
|
46
|
-
|
47
|
-
...
|
48
|
-
```
|
49
|
-
|
50
|
-
* If you're using Sinatra
|
51
|
-
|
52
|
-
Insert the following into either the Application File or config.ru.
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
...
|
56
|
-
|
57
|
-
require 'wovnrb'
|
58
|
-
|
59
|
-
use Wovnrb::Interceptor, {
|
60
|
-
:project_token => 'EnS!t3',
|
61
|
-
:default_lang => 'en',
|
62
|
-
:supported_langs => ['en'],
|
63
|
-
:url_pattern => 'path'
|
64
|
-
}
|
65
|
-
|
66
|
-
...
|
67
|
-
```
|
68
|
-
|
69
|
-
After completing setup, start the Ruby Application, and make sure the WOVN.io library is working correctly.
|
70
|
-
|
71
|
-
## 2. Parameter Setting
|
72
|
-
|
73
|
-
The following is a list of the WOVN.io Ruby Library's valid parameters.
|
74
|
-
|
75
|
-
Parameter Name | Required | Default Setting
|
76
|
-
------------------ | -------- | ----------------
|
77
|
-
project_token | yes | ''
|
78
|
-
default_lang | yes | 'en'
|
79
|
-
supported_langs | yes | ['en']
|
80
|
-
url_pattern | yes | 'path'
|
81
|
-
lang_param_name | | 'wovn'
|
82
|
-
query | | []
|
83
|
-
ignore_class | | []
|
84
|
-
translate_fragment | | true
|
85
|
-
ignore_paths | | []
|
86
|
-
|
87
|
-
### 2.1. project_token
|
88
|
-
|
89
|
-
Set your WOVN.io Account's Project token. This parameter is required.
|
90
|
-
|
91
|
-
### 2.2. default_lang
|
92
|
-
|
93
|
-
This sets the Ruby application's default language. The default value is English ('en').
|
94
|
-
|
95
|
-
If, for a requested page, the default language parameter is included in the URL, the request is redirected before translating. The default_lang parameter is used for this purpose.
|
96
|
-
|
97
|
-
If the default_lang is set to 'en', when receiving a request for the following URL,
|
98
|
-
|
99
|
-
https://wovn.io/en/contact
|
100
|
-
|
101
|
-
Then the library will redirect to the following URL.
|
102
|
-
|
103
|
-
https://wovn.io/contact
|
104
|
-
|
105
|
-
### 2.3. supported_langs
|
106
|
-
This tells the library which languages are being used on the website (including
|
107
|
-
the original language). This setting allows for inserting metadata necessary for
|
108
|
-
SEO (Search Engine Optimization).
|
109
|
-
|
110
|
-
If your website is in English and you are using WOVN.io to localize it in
|
111
|
-
Japanese, then you should use the following setting:
|
112
|
-
```
|
113
|
-
:supported_langs => ['en', 'ja']
|
114
|
-
```
|
115
|
-
**Note:** The order of the languages in the list does not matter.
|
116
|
-
|
117
|
-
### 2.4. url_pattern
|
118
|
-
|
119
|
-
The Library works in the Ruby Application by adding new URLs to be translated. You can set the type of url with the `url_pattern` parameter. There are 3 types that can be set.
|
120
|
-
|
121
|
-
parameters | Translated page's URL | Notes
|
122
|
-
----------- | ------------------------------- | -------
|
123
|
-
'path' | https://wovn.io/ja/contact | Default Value. If no settings have been set, url_pattern defaults to this value.
|
124
|
-
'subdomain' | https://ja.wovn.io/contact | DNS settings must be set.
|
125
|
-
'query' | https://wovn.io/contact?wovn=ja | The least amount of changes to the application required to complete setup.
|
126
|
-
|
127
|
-
※ The following is an example of a URL that has been translated by the library using the above URLs.
|
128
|
-
|
129
|
-
https://wovn.io/contact
|
130
|
-
|
131
|
-
### 2.5 lang_param_name
|
132
|
-
This parameter is only valid for when `url_pattern_name` is set to `'query'`.
|
133
|
-
|
134
|
-
It allows you to set the query parameter name for declaring the language of the
|
135
|
-
page. The default value for this setting is `'wovn'`, such that a page URL in
|
136
|
-
translated language English has the form
|
137
|
-
`https://my-website.com/index.php?wovn=en`. If you instead set the value to
|
138
|
-
`'lang'`, then the later URL example would have the form
|
139
|
-
`https://my-website.com/index.php?lang=en`.
|
140
|
-
|
141
|
-
### 2.6. query
|
142
|
-
|
143
|
-
WOVN.io ignores query parameters when searching a translated page. If you want to add a query parameter to translated page's URL, you should configure the `query` parameter. (You need to configure WOVN.io too)
|
144
|
-
|
145
|
-
https://wovn.io/ja/contact?os=mac&keyboard=us
|
146
|
-
|
147
|
-
If the `default_lang` is 'en', and the query is set to '', the above URL will be modified into the following URL to search for the page's translation.
|
148
|
-
|
149
|
-
https://wovn.io/contact
|
150
|
-
|
151
|
-
If the `default_lang` is 'en', and the query is set to 'os', the above URL will be modified into the following URL to search for the page's translation.
|
152
|
-
|
153
|
-
https://wovn.io/contact?os=mac
|
154
|
-
|
155
|
-
### 2.7. ignore_class
|
156
|
-
|
157
|
-
This sets "Ignore class" which prevents WOVN from translating HTML elements that have a class contained in this array.
|
158
|
-
|
159
|
-
### 2.8. translate_fragment
|
160
|
-
|
161
|
-
This option allows to disable translating partial HTML content. By default,
|
162
|
-
partial HTML content is translated but no widget snippet is added. Set
|
163
|
-
`translate_fragment` to `false` to prevent translating partial HTML content.
|
164
|
-
|
165
|
-
### 2.9 ignore_paths
|
166
|
-
|
167
|
-
This parameter tells WOVN.rb to not localize content withing given directories.
|
168
|
-
|
169
|
-
The directories given will only be matched against the beginning of the URL path.
|
170
|
-
|
171
|
-
For instance, if you want to not localize the admin directory of your website, you should add the following to you WOVN.rb configuration.
|
172
|
-
```
|
173
|
-
'ignore_paths' => ['/admin/']
|
174
|
-
```
|
175
|
-
|
176
|
-
## 3. Contributing
|
177
|
-
|
178
|
-
1. Fork it ( https://github.com/WOVNio/wovnrb/fork )
|
179
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
180
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
181
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
182
|
-
5. Create a new Pull Request
|