wovnrb 3.9.0 → 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0283acd73cab4171aefb1bb183832a0536a2c88fd4c62ac3fef0befee06a2a2
4
- data.tar.gz: b8eebae5190864b55c02f53c30e166ec955ce08c19fd7866185a7ec50df54c3c
3
+ metadata.gz: 59061d2931f333910c0405d78142ffca7317123435456d5524a2b661c3ce6ab8
4
+ data.tar.gz: 0cf2cb499d0f2626f8a9785aa2cc70b12d692c83344a602f428e2e13979aecef
5
5
  SHA512:
6
- metadata.gz: c1b6e6f940f60e059d0b2527108660f43e17d82ca6b57ec7a4f2ec127062482494bc684e7c01bd86453d776dbe53159f19f2984a59a373e3b95920bfd1c78ee0
7
- data.tar.gz: 9851f866c7df91b312f99790b165407432e6d77f6fa95774cee4016ef3ec35f7e7e0d291396dd20c48a420aaa6771d8196e53641eef53fc3abdd24cb96aa80f8
6
+ metadata.gz: 3d2e73e65e1154eea7d199d548b03937049c58e0de5e46c38cf342f73246f01ae35d976bf4eb0fda31521b821293248274b3c52d8135686198bb5ffb68fe4d45
7
+ data.tar.gz: 1993fe20280c540a57728ca5537f71a4a8d579f2d642db57ff9133f5cb8bb31fba15682be529145ad9a218c1b75679a4aa9460b919645b51f41be8bf9f5fb60a
data/README.en.md CHANGED
@@ -1,249 +1,256 @@
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 => 'ja',
43
- :supported_langs => ['ja', en'],
44
- :url_pattern => 'path'
45
- }
46
-
47
- ...
48
- ```
49
-
50
- The WOVN.rb Rails middleware must also be installed. See [2.10 - install_middleware](#2.10-install_middleware)
51
-
52
- * If you're using Sinatra
53
-
54
- Insert the following into either the Application File or config.ru.
55
-
56
- ```ruby
57
- ...
58
-
59
- require 'wovnrb'
60
-
61
- use Wovnrb::Interceptor, {
62
- :project_token => 'EnS!t3',
63
- :default_lang => 'ja',
64
- :supported_langs => ['ja', 'en'],
65
- :url_pattern => 'path'
66
- }
67
-
68
- ...
69
- ```
70
-
71
- After completing setup, start the Ruby Application, and make sure the WOVN.io library is working correctly.
72
-
73
- ## 2. Parameter Setting
74
-
75
- The following is a list of the WOVN.io Ruby Library's valid parameters.
76
-
77
- Parameter Name | Required | Default Setting
78
- -------------------------------| -------- | ----------------
79
- project_token | yes | ''
80
- default_lang | yes | 'ja'
81
- supported_langs | yes | ['ja', 'en']
82
- url_pattern | yes | 'path'
83
- lang_param_name | | 'wovn'
84
- query | | []
85
- ignore_class | | []
86
- translate_fragment | | true
87
- ignore_paths | | []
88
- install_middleware | | true
89
- compress_api_requests | | true
90
- api_timeout_seconds | | 1.0
91
- api_timeout_search_engine_bots | | 5.0
92
- translate_canonical_tag | | true
93
- custom_domain_langs | | {}
94
-
95
- ### 2.1. project_token
96
-
97
- Set your WOVN.io Account's Project token. This parameter is required.
98
-
99
- ### 2.2. default_lang
100
-
101
- This sets the Ruby application's default language. The default value is English ('en').
102
-
103
- 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.
104
-
105
- If the default_lang is set to 'en', when receiving a request for the following URL,
106
-
107
- https://wovn.io/en/contact
108
-
109
- Then the library will redirect to the following URL.
110
-
111
- https://wovn.io/contact
112
-
113
- ### 2.3. supported_langs
114
- This tells the library which languages are being used on the website (including
115
- the original language). This setting allows for inserting metadata necessary for
116
- SEO (Search Engine Optimization).
117
-
118
- If your website is in English and you are using WOVN.io to localize it in
119
- Japanese, then you should use the following setting:
120
- ```
121
- :supported_langs => ['en', 'ja']
122
- ```
123
- **Note:** The order of the languages in the list does not matter.
124
-
125
- ### 2.4. url_pattern
126
-
127
- 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 4 types that can be set.
128
-
129
- parameters | Translated page's URL | Notes
130
- --------------- | -------------------------------- | -------
131
- 'path' | https://wovn.io/ja/contact | Default Value. If no settings have been set, url_pattern defaults to this value.
132
- 'subdomain' | https://ja.wovn.io/contact | DNS settings must be set.
133
- 'query' | https://wovn.io/contact?wovn=ja | The least amount of changes to the application required to complete setup.
134
- 'custom_domain' | Depends on `custom_domain_langs` | See [Section 2.15.](#215-custom_domain_langs).
135
-
136
- ※ The following is an example of a URL that has been translated by the library using the above URLs.
137
-
138
- https://wovn.io/contact
139
-
140
- ### 2.5. lang_param_name
141
- This parameter is only valid for when `url_pattern` is set to `'query'`.
142
-
143
- It allows you to set the query parameter name for declaring the language of the
144
- page. The default value for this setting is `'wovn'`, such that a page URL in
145
- translated language English has the form
146
- `https://my-website.com/index.php?wovn=en`. If you instead set the value to
147
- `'lang'`, then the later URL example would have the form
148
- `https://my-website.com/index.php?lang=en`.
149
-
150
- ### 2.6. query
151
-
152
- 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)
153
-
154
- https://wovn.io/ja/contact?os=mac&keyboard=us
155
-
156
- 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.
157
-
158
- https://wovn.io/contact
159
-
160
- 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.
161
-
162
- https://wovn.io/contact?os=mac
163
-
164
- ### 2.7. ignore_class
165
-
166
- This sets "Ignore class" which prevents WOVN from translating HTML elements that have a class contained in this array.
167
-
168
- ### 2.8. translate_fragment
169
-
170
- This option allows to disable translating partial HTML content. By default,
171
- partial HTML content is translated but no widget snippet is added. Set
172
- `translate_fragment` to `false` to prevent translating partial HTML content.
173
-
174
- ### 2.9. ignore_paths
175
-
176
- This parameter tells WOVN.rb to not localize content withing given directories.
177
-
178
- The directories given will only be matched against the beginning of the URL path.
179
-
180
- For instance, if you want to not localize the admin directory of your website, you should add the following to you WOVN.rb configuration.
181
- ```
182
- 'ignore_paths' => ['/admin/']
183
- ```
184
-
185
- ### 2.10. install_middleware
186
-
187
- When using WOVN.rb in a Rails environment, this parameter controls whether the WOVN.rb middleware will be automatically installed or not.
188
-
189
- By default, WOVN.rb is automatically installed as the first middleware.
190
- If you are using Rack::Deflater or other middleware that needs to be executed first, set this parameter to `false` and manually insert the middleware appropriately.
191
- WOVN.rb needs to be added after any compression middleware.
192
-
193
- ```ruby
194
- config.middleware.use Rack::Deflater
195
- config.middleware.insert_after Rack::Deflater, Wovnrb::Interceptor
196
-
197
- config.wovnrb = {
198
- :project_token => 'EnS!t3',
199
- :default_lang => 'en',
200
- :supported_langs => ['en'],
201
- :url_pattern => 'path',
202
- :install_middleware => false
203
- }
204
- ```
205
-
206
- ### 2.11. compress_api_requests
207
-
208
- By default, requests to the translation API will be sent with gzip compression. Set to false to disable compression.
209
-
210
- ### 2.12. api_timeout_seconds
211
- Configures the amount of time in seconds wovnrb will wait for the translation API for a response before the
212
- request is considered timed-out. This setting defaults to `1.0`.
213
-
214
- ### 2.13. api_timeout_search_engine_bots
215
- Similar to `api_timeout_seconds`, this timeout setting is applied when handling requests made by search engine bots.
216
- Currently, bots from Google, Yahoo, Bing, Yandex, DuckDuckGo and Baidu are supported. This setting
217
- defaults to `5.0`.
218
-
219
- ### 2.14. translate_canonical_tag
220
- Configures if wovnrb should automatically translate existing canonical tag in the HTML. When set to `true`, wovnrb
221
- will translate the canonical URL with the current language code according to your `url_pattern` setting.
222
- This setting defaults to `true`.
223
-
224
- ### 2.15. custom_domain_langs
225
- This parameter is valid and required, when `url_pattern` is `custom_domain`.
226
- Set `custom_domain_langs` for all languages declared in `supported_langs`.
227
-
228
- ```ruby
229
- config.wovnrb = {
230
- # ...
231
- :custom_domain_langs => {
232
- 'en' => { 'url' => 'wovn.io/en' },
233
- 'ja' => { 'url' => 'ja.wovn.io' },
234
- 'fr' => { 'url' => 'fr.wovn.co.jp' }
235
- }
236
- }
237
- ```
238
-
239
- For the example above, all request URLs that match `wovn.io/en/*` will be considered as requests in English language.
240
- All request URLs other than the above that match `ja.wovn.io/*` will be considered as requests in Japanese langauge.
241
- And, request URLs that match `fr.wovn.co.jp/*` will be considered as requests in French langauge.
242
- With the above example configuration, the page `http://ja.wovn.io/about.html` in Japanese language will have the URL `http://wovn.io/en/about.html` as English language.
243
-
244
- `custom_domain_langs` setting may only be used together with the `url_pattern = custom_domain` setting.
245
-
246
- If this setting is used, each language declared in `supported_langs` must be given a custom domain.
247
-
248
- The path declared for your original language must match the structure of the actual web server.
249
- In other words, you cannot use this setting to change the request path of your content in original language.
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 => 'ja',
43
+ :supported_langs => ['ja', en'],
44
+ :url_pattern => 'path'
45
+ }
46
+
47
+ ...
48
+ ```
49
+
50
+ The WOVN.rb Rails middleware must also be installed. See [2.10 - install_middleware](#210-install_middleware)
51
+
52
+ * If you're using Sinatra
53
+
54
+ Insert the following into either the Application File or config.ru.
55
+
56
+ ```ruby
57
+ ...
58
+
59
+ require 'wovnrb'
60
+
61
+ use Wovnrb::Interceptor, {
62
+ :project_token => 'EnS!t3',
63
+ :default_lang => 'ja',
64
+ :supported_langs => ['ja', 'en'],
65
+ :url_pattern => 'path'
66
+ }
67
+
68
+ ...
69
+ ```
70
+
71
+ After completing setup, start the Ruby Application, and make sure the WOVN.io library is working correctly.
72
+
73
+ ## 2. Parameter Setting
74
+
75
+ The following is a list of the WOVN.io Ruby Library's valid parameters.
76
+
77
+ Parameter Name | Required | Default Setting
78
+ -------------------------------| -------- | ----------------
79
+ project_token | yes | ''
80
+ default_lang | yes | 'ja'
81
+ supported_langs | yes | ['ja', 'en']
82
+ url_pattern | yes | 'path'
83
+ lang_param_name | | 'wovn'
84
+ query | | []
85
+ ignore_class | | []
86
+ translate_fragment | | true
87
+ ignore_paths | | []
88
+ install_middleware | | true
89
+ compress_api_requests | | true
90
+ api_timeout_seconds | | 1.0
91
+ api_timeout_search_engine_bots | | 5.0
92
+ translate_canonical_tag | | true
93
+ custom_domain_langs | | {}
94
+ insert_hreflangs | | true
95
+
96
+ ### 2.1. project_token
97
+
98
+ Set your WOVN.io Account's Project token. This parameter is required.
99
+
100
+ ### 2.2. default_lang
101
+
102
+ This sets the Ruby application's default language. The default value is English ('en').
103
+
104
+ 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.
105
+
106
+ If the default_lang is set to 'en', when receiving a request for the following URL,
107
+
108
+ https://wovn.io/en/contact
109
+
110
+ Then the library will redirect to the following URL.
111
+
112
+ https://wovn.io/contact
113
+
114
+ ### 2.3. supported_langs
115
+ This tells the library which languages are being used on the website (including
116
+ the original language). This setting allows for inserting metadata necessary for
117
+ SEO (Search Engine Optimization).
118
+
119
+ If your website is in English and you are using WOVN.io to localize it in
120
+ Japanese, then you should use the following setting:
121
+ ```
122
+ :supported_langs => ['en', 'ja']
123
+ ```
124
+ **Note:** The order of the languages in the list does not matter.
125
+
126
+ ### 2.4. url_pattern
127
+
128
+ 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 4 types that can be set.
129
+
130
+ parameters | Translated page's URL | Notes
131
+ --------------- | -------------------------------- | -------
132
+ 'path' | https://wovn.io/ja/contact | Default Value. If no settings have been set, url_pattern defaults to this value.
133
+ 'subdomain' | https://ja.wovn.io/contact | DNS settings must be set.
134
+ 'query' | https://wovn.io/contact?wovn=ja | The least amount of changes to the application required to complete setup.
135
+ 'custom_domain' | Depends on `custom_domain_langs` | See [Section 2.15.](#215-custom_domain_langs).
136
+
137
+ ※ The following is an example of a URL that has been translated by the library using the above URLs.
138
+
139
+ https://wovn.io/contact
140
+
141
+ ### 2.5. lang_param_name
142
+ This parameter is only valid for when `url_pattern` is set to `'query'`.
143
+
144
+ It allows you to set the query parameter name for declaring the language of the
145
+ page. The default value for this setting is `'wovn'`, such that a page URL in
146
+ translated language English has the form
147
+ `https://my-website.com/index.php?wovn=en`. If you instead set the value to
148
+ `'lang'`, then the later URL example would have the form
149
+ `https://my-website.com/index.php?lang=en`.
150
+
151
+ ### 2.6. query
152
+
153
+ 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)
154
+
155
+ https://wovn.io/ja/contact?os=mac&keyboard=us
156
+
157
+ 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.
158
+
159
+ https://wovn.io/contact
160
+
161
+ 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.
162
+
163
+ https://wovn.io/contact?os=mac
164
+
165
+ ### 2.7. ignore_class
166
+
167
+ This sets "Ignore class" which prevents WOVN from translating HTML elements that have a class contained in this array.
168
+
169
+ ### 2.8. translate_fragment
170
+
171
+ This option allows to disable translating partial HTML content. By default,
172
+ partial HTML content is translated but no widget snippet is added. Set
173
+ `translate_fragment` to `false` to prevent translating partial HTML content.
174
+
175
+ ### 2.9. ignore_paths
176
+
177
+ This parameter tells WOVN.rb to not localize content withing given directories.
178
+
179
+ The directories given will only be matched against the beginning of the URL path.
180
+
181
+ For instance, if you want to not localize the admin directory of your website, you should add the following to you WOVN.rb configuration.
182
+ ```
183
+ 'ignore_paths' => ['/admin/']
184
+ ```
185
+
186
+ ### 2.10. install_middleware
187
+
188
+ When using WOVN.rb in a Rails environment, this parameter controls whether the WOVN.rb middleware will be automatically installed or not.
189
+
190
+ By default, WOVN.rb is automatically installed as the first middleware.
191
+ If you are using Rack::Deflater or other middleware that needs to be executed first, set this parameter to `false` and manually insert the middleware appropriately.
192
+ WOVN.rb needs to be added after any compression middleware.
193
+
194
+ ```ruby
195
+ config.middleware.use Rack::Deflater
196
+ config.middleware.insert_after Rack::Deflater, Wovnrb::Interceptor
197
+
198
+ config.wovnrb = {
199
+ :project_token => 'EnS!t3',
200
+ :default_lang => 'en',
201
+ :supported_langs => ['en'],
202
+ :url_pattern => 'path',
203
+ :install_middleware => false
204
+ }
205
+ ```
206
+
207
+ ### 2.11. compress_api_requests
208
+
209
+ By default, requests to the translation API will be sent with gzip compression. Set to false to disable compression.
210
+
211
+ ### 2.12. api_timeout_seconds
212
+ Configures the amount of time in seconds WOVN.rb will wait for the translation API for a response before the
213
+ request is considered timed-out. This setting defaults to `1.0`.
214
+
215
+ ### 2.13. api_timeout_search_engine_bots
216
+ Similar to `api_timeout_seconds`, this timeout setting is applied when handling requests made by search engine bots.
217
+ Currently, bots from Google, Yahoo, Bing, Yandex, DuckDuckGo and Baidu are supported. This setting
218
+ defaults to `5.0`.
219
+
220
+ ### 2.14. translate_canonical_tag
221
+ Configures if WOVN.rb should automatically translate existing canonical tag in the HTML. When set to `true`, WOVN.rb
222
+ will translate the canonical URL with the current language code according to your `url_pattern` setting.
223
+ This setting defaults to `true`.
224
+
225
+ ### 2.15. custom_domain_langs
226
+ This parameter is valid and required, when `url_pattern` is `custom_domain`.
227
+ Set `custom_domain_langs` for all languages declared in `supported_langs`.
228
+
229
+ ```ruby
230
+ config.wovnrb = {
231
+ # ...
232
+ :custom_domain_langs => {
233
+ 'en' => { 'url' => 'wovn.io/en' },
234
+ 'ja' => { 'url' => 'ja.wovn.io' },
235
+ 'fr' => { 'url' => 'fr.wovn.co.jp' }
236
+ }
237
+ }
238
+ ```
239
+
240
+ For the example above, all request URLs that match `wovn.io/en/*` will be considered as requests in English language.
241
+ All request URLs other than the above that match `ja.wovn.io/*` will be considered as requests in Japanese langauge.
242
+ And, request URLs that match `fr.wovn.co.jp/*` will be considered as requests in French langauge.
243
+ With the above example configuration, the page `http://ja.wovn.io/about.html` in Japanese language will have the URL `http://wovn.io/en/about.html` as English language.
244
+
245
+ `custom_domain_langs` setting may only be used together with the `url_pattern = custom_domain` setting.
246
+
247
+ If this setting is used, each language declared in `supported_langs` must be given a custom domain.
248
+
249
+ The path declared for your original language must match the structure of the actual web server.
250
+ In other words, you cannot use this setting to change the request path of your content in original language.
251
+
252
+ ### 2.16. `insert_hreflangs`
253
+ This parameter tells WOVN.rb to insert link tag with hreflang.
254
+ If setting is on, the tag like `<link rel="alternate" hreflang="en" href="https://my-website.com/en/">` will be inserted for published languages.
255
+
256
+ If setting is off, WOVN.rb doesn't add any change to link tag with hreflang.