wovnrb 2.2.0 → 2.5.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 +2 -2
- data/README.en.md +174 -0
- data/README.ja.md +180 -0
- data/README.md +1 -0
- data/lib/wovnrb.rb +15 -4
- data/lib/wovnrb/headers.rb +25 -41
- data/lib/wovnrb/lang.rb +77 -40
- data/lib/wovnrb/railtie.rb +1 -1
- data/lib/wovnrb/services/html_converter.rb +5 -10
- data/lib/wovnrb/services/html_replace_marker.rb +7 -1
- data/lib/wovnrb/settings.rb +9 -1
- data/lib/wovnrb/store.rb +1 -1
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/headers_test.rb +72 -25
- data/test/lib/lang_test.rb +10 -40
- data/test/lib/services/html_converter_test.rb +41 -15
- data/test/lib/services/html_replace_marker_test.rb +81 -5
- data/test/lib/store_test.rb +1 -0
- data/test/lib/wovnrb_test.rb +140 -1
- data/test/test_helper.rb +4 -2
- data/wovnrb.gemspec +1 -1
- metadata +9 -7
- data/README.md +0 -170
data/wovnrb.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'activesupport'
|
23
23
|
spec.add_dependency 'addressable'
|
24
24
|
spec.add_dependency 'lz4-ruby'
|
25
|
-
spec.add_dependency 'nokogiri', '
|
25
|
+
spec.add_dependency 'nokogiri', '>= 1.8.1'
|
26
26
|
spec.add_dependency 'nokogumbo', '>= 1.4.0', '< 2.0.0'
|
27
27
|
spec.add_dependency 'rack'
|
28
28
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wovnrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandford
|
8
8
|
- Antoine David
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
name: nokogiri
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 1.8.1
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 1.8.1
|
70
70
|
- !ruby/object:Gem::Dependency
|
@@ -410,6 +410,8 @@ files:
|
|
410
410
|
- Gemfile
|
411
411
|
- LICENSE.txt
|
412
412
|
- PULL_REQUEST_TEMPLATE
|
413
|
+
- README.en.md
|
414
|
+
- README.ja.md
|
413
415
|
- README.md
|
414
416
|
- Rakefile
|
415
417
|
- lib/wovnrb.rb
|
@@ -446,7 +448,7 @@ homepage: ''
|
|
446
448
|
licenses:
|
447
449
|
- MIT
|
448
450
|
metadata: {}
|
449
|
-
post_install_message:
|
451
|
+
post_install_message:
|
450
452
|
rdoc_options: []
|
451
453
|
require_paths:
|
452
454
|
- lib
|
@@ -462,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
462
464
|
version: '0'
|
463
465
|
requirements: []
|
464
466
|
rubygems_version: 3.0.3
|
465
|
-
signing_key:
|
467
|
+
signing_key:
|
466
468
|
specification_version: 4
|
467
469
|
summary: Gem for WOVN.io
|
468
470
|
test_files:
|
data/README.md
DELETED
@@ -1,170 +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
|
-
|
86
|
-
### 2.1. project_token
|
87
|
-
|
88
|
-
Set your WOVN.io Account's Project token. This parameter is required.
|
89
|
-
|
90
|
-
### 2.2. default_lang
|
91
|
-
|
92
|
-
This sets the Ruby application's default language. The default value is English ('en').
|
93
|
-
|
94
|
-
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.
|
95
|
-
|
96
|
-
If the default_lang is set to 'en', when receiving a request for the following URL,
|
97
|
-
|
98
|
-
https://wovn.io/en/contact
|
99
|
-
|
100
|
-
Then the library will redirect to the following URL.
|
101
|
-
|
102
|
-
https://wovn.io/contact
|
103
|
-
|
104
|
-
### 2.3. supported_langs
|
105
|
-
This tells the library which languages are being used on the website (including
|
106
|
-
the original language). This setting allows for inserting metadata necessary for
|
107
|
-
SEO (Search Engine Optimization).
|
108
|
-
|
109
|
-
If your website is in English and you are using WOVN.io to localize it in
|
110
|
-
Japanese, then you should use the following setting:
|
111
|
-
```
|
112
|
-
:supported_langs => ['en', 'ja']
|
113
|
-
```
|
114
|
-
**Note:** The order of the languages in the list does not matter.
|
115
|
-
|
116
|
-
### 2.4. url_pattern
|
117
|
-
|
118
|
-
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.
|
119
|
-
|
120
|
-
parameters | Translated page's URL | Notes
|
121
|
-
----------- | ------------------------------- | -------
|
122
|
-
'path' | https://wovn.io/ja/contact | Default Value. If no settings have been set, url_pattern defaults to this value.
|
123
|
-
'subdomain' | https://ja.wovn.io/contact | DNS settings must be set.
|
124
|
-
'query' | https://wovn.io/contact?wovn=ja | The least amount of changes to the application required to complete setup.
|
125
|
-
|
126
|
-
※ The following is an example of a URL that has been translated by the library using the above URLs.
|
127
|
-
|
128
|
-
https://wovn.io/contact
|
129
|
-
|
130
|
-
### 2.5 lang_param_name
|
131
|
-
This parameter is only valid for when `url_pattern_name` is set to `'query'`.
|
132
|
-
|
133
|
-
It allows you to set the query parameter name for declaring the language of the
|
134
|
-
page. The default value for this setting is `'wovn'`, such that a page URL in
|
135
|
-
translated language English has the form
|
136
|
-
`https://my-website.com/index.php?wovn=en`. If you instead set the value to
|
137
|
-
`'lang'`, then the later URL example would have the form
|
138
|
-
`https://my-website.com/index.php?lang=en`.
|
139
|
-
|
140
|
-
### 2.6. query
|
141
|
-
|
142
|
-
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)
|
143
|
-
|
144
|
-
https://wovn.io/ja/contact?os=mac&keyboard=us
|
145
|
-
|
146
|
-
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.
|
147
|
-
|
148
|
-
https://wovn.io/contact
|
149
|
-
|
150
|
-
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.
|
151
|
-
|
152
|
-
https://wovn.io/contact?os=mac
|
153
|
-
|
154
|
-
### 2.7. ignore_class
|
155
|
-
|
156
|
-
This sets "Ignore class" which prevents WOVN from translating HTML elements that have a class contained in this array.
|
157
|
-
|
158
|
-
### 2.8. translate_fragment
|
159
|
-
|
160
|
-
This option allows to disable translating partial HTML content. By default,
|
161
|
-
partial HTML content is translated but no widget snippet is added. Set
|
162
|
-
`translate_fragment` to `false` to prevent translating partial HTML content.
|
163
|
-
|
164
|
-
## 3. Contributing
|
165
|
-
|
166
|
-
1. Fork it ( https://github.com/WOVNio/wovnrb/fork )
|
167
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
168
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
169
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
170
|
-
5. Create a new Pull Request
|