wovnrb 3.8.0 → 3.10.0

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: 315ed96f41cbfa7d479fe520e53fe2e740ac5a597b51a30326d9ed24c4da40c1
4
- data.tar.gz: 51d39551f5594c266c33f84613235cf1f8ac88c351ea1468601dd0f73b257bdd
3
+ metadata.gz: 9a9f34331806d469cb98a5fd0689e5ddd51ff69e7d3e59308d4bfae1f59b4c3b
4
+ data.tar.gz: 7bbee9e1aa4be8f03ea02ffc9db335c3c025e4fc33b93243ae3231e34642e0e6
5
5
  SHA512:
6
- metadata.gz: 649285b3c4a0ed37c842315f21f3fe73d8fe2b097296ff4df5d0a74479982db526a3b41428b32a568a7b0b987deeeda3c9230b3421b302d3f6a2999caec978d9
7
- data.tar.gz: 75157d25a342cd57d6eb917774177774521b6a34db62049be1da8350459677121091bccbfd9a79672b475a8a6f560ac4b9282178e33a2204654177a50d3f3e0f
6
+ metadata.gz: ff78c6e30e99f2754975d15a8e2528c048319a64a264e4bd371f04446a34d16eafd4324554a66ffe93ac45b4d0d00d90a0e0e7fa013fd894f44a7f90653789cc
7
+ data.tar.gz: 6354dd1d0afcbc9fcc287438d13dce92397a15f282dec428e4854120ccf75899fafd527ab47b08f5068d310403e3c976c5f5556a9237657f71de1d0b1bc6fcba
data/README.en.md CHANGED
@@ -1,220 +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
-
94
- ### 2.1. project_token
95
-
96
- Set your WOVN.io Account's Project token. This parameter is required.
97
-
98
- ### 2.2. default_lang
99
-
100
- This sets the Ruby application's default language. The default value is English ('en').
101
-
102
- 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.
103
-
104
- If the default_lang is set to 'en', when receiving a request for the following URL,
105
-
106
- https://wovn.io/en/contact
107
-
108
- Then the library will redirect to the following URL.
109
-
110
- https://wovn.io/contact
111
-
112
- ### 2.3. supported_langs
113
- This tells the library which languages are being used on the website (including
114
- the original language). This setting allows for inserting metadata necessary for
115
- SEO (Search Engine Optimization).
116
-
117
- If your website is in English and you are using WOVN.io to localize it in
118
- Japanese, then you should use the following setting:
119
- ```
120
- :supported_langs => ['en', 'ja']
121
- ```
122
- **Note:** The order of the languages in the list does not matter.
123
-
124
- ### 2.4. url_pattern
125
-
126
- 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.
127
-
128
- parameters | Translated page's URL | Notes
129
- ----------- | ------------------------------- | -------
130
- 'path' | https://wovn.io/ja/contact | Default Value. If no settings have been set, url_pattern defaults to this value.
131
- 'subdomain' | https://ja.wovn.io/contact | DNS settings must be set.
132
- 'query' | https://wovn.io/contact?wovn=ja | The least amount of changes to the application required to complete setup.
133
-
134
- The following is an example of a URL that has been translated by the library using the above URLs.
135
-
136
- https://wovn.io/contact
137
-
138
- ### 2.5 lang_param_name
139
- This parameter is only valid for when `url_pattern` is set to `'query'`.
140
-
141
- It allows you to set the query parameter name for declaring the language of the
142
- page. The default value for this setting is `'wovn'`, such that a page URL in
143
- translated language English has the form
144
- `https://my-website.com/index.php?wovn=en`. If you instead set the value to
145
- `'lang'`, then the later URL example would have the form
146
- `https://my-website.com/index.php?lang=en`.
147
-
148
- ### 2.6. query
149
-
150
- 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)
151
-
152
- https://wovn.io/ja/contact?os=mac&keyboard=us
153
-
154
- 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.
155
-
156
- https://wovn.io/contact
157
-
158
- 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.
159
-
160
- https://wovn.io/contact?os=mac
161
-
162
- ### 2.7. ignore_class
163
-
164
- This sets "Ignore class" which prevents WOVN from translating HTML elements that have a class contained in this array.
165
-
166
- ### 2.8. translate_fragment
167
-
168
- This option allows to disable translating partial HTML content. By default,
169
- partial HTML content is translated but no widget snippet is added. Set
170
- `translate_fragment` to `false` to prevent translating partial HTML content.
171
-
172
- ### 2.9 ignore_paths
173
-
174
- This parameter tells WOVN.rb to not localize content withing given directories.
175
-
176
- The directories given will only be matched against the beginning of the URL path.
177
-
178
- For instance, if you want to not localize the admin directory of your website, you should add the following to you WOVN.rb configuration.
179
- ```
180
- 'ignore_paths' => ['/admin/']
181
- ```
182
-
183
- ### 2.10 install_middleware
184
-
185
- When using WOVN.rb in a Rails environment, this parameter controls whether the WOVN.rb middleware will be automatically installed or not.
186
-
187
- By default, WOVN.rb is automatically installed as the first middleware.
188
- 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.
189
- WOVN.rb needs to be added after any compression middleware.
190
-
191
- ```ruby
192
- config.middleware.use Rack::Deflater
193
- config.middleware.insert_after Rack::Deflater, Wovnrb::Interceptor
194
-
195
- config.wovnrb = {
196
- :project_token => 'EnS!t3',
197
- :default_lang => 'en',
198
- :supported_langs => ['en'],
199
- :url_pattern => 'path',
200
- :install_middleware => false
201
- }
202
- ```
203
-
204
- ### 2.11 compress_api_requests
205
-
206
- By default, requests to the translation API will be sent with gzip compression. Set to false to disable compression.
207
-
208
- ### 2.12 api_timeout_seconds
209
- Configures the amount of time in seconds wovnrb will wait for the translation API for a response before the
210
- request is considered timed-out. This setting defaults to `1.0`.
211
-
212
- ### 2.13 api_timeout_search_engine_bots
213
- Similar to `api_timeout_seconds`, this timeout setting is applied when handling requests made by search engine bots.
214
- Currently, bots from Google, Yahoo, Bing, Yandex, DuckDuckGo and Baidu are supported. This setting
215
- defaults to `5.0`.
216
-
217
- ### 2.14 translate_canonical_tag
218
- Configures if wovnrb should automatically translate existing canonical tag in the HTML. When set to `true`, wovnrb
219
- will translate the canonical URL with the current language code according to your `url_pattern` setting.
220
- This setting defaults to `true`.
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.