wovnrb 3.11.0 → 3.11.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: 463dae110c0cc5db174f67ec3b1791b4e48992ee92e7b605d9b2e574d3267780
4
- data.tar.gz: bb2aeb497221ac2d4d3c9950b365ba15aa0856f874110ccdff243743fcea4bbd
3
+ metadata.gz: 363a963f8aa66c621e8a5a9c74e539ab34aa5b691db5b13c184d10b2a9d3bdce
4
+ data.tar.gz: 6f3aad667b5a978fbb3c4df193ec25eeb567193d7b8be46ca32b4abb2d4f3257
5
5
  SHA512:
6
- metadata.gz: 95a0ef9d74680ef0178de3d495cc9234bf3912bf15b7e0cee14deab8e5c1c49f350a24f5f7842192d75318463f07afac2682354afbff813510c706885a846285
7
- data.tar.gz: 7b2b070b2a5c2197a119c653360b613863c7e78d73c7ea1814edbdc2fd57f40ad59bba7b2cd106694edf27c1d7bd5519b95c37277856bd6d43646517d7dd865a
6
+ metadata.gz: d9b16d7c6fe502f7d4669f32360a7f1827ffb6b889fffc609ad1aed1a577209e56737916ced62d891116f3dcd747f69ba136850a1ca52d5aaf06e2dd30e3c3c4
7
+ data.tar.gz: 633ef1dbc42ed6943b789133f0574e758bda8867101392dae272353d97d79cb308c37108740aa7aa0499ef48acfbfc59244e1c47f91c69f7781a53c96e1d93a8
data/README.en.md CHANGED
@@ -1,256 +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](#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.
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.