transifex-interface-ruby 0.0.1 → 0.0.2
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 +6 -14
- data/.gitignore +17 -17
- data/.rspec +2 -0
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +517 -513
- data/Rakefile +1 -1
- data/lib/transifex.rb +84 -87
- data/lib/transifex/crud_requests.rb +43 -33
- data/lib/transifex/errors.rb +4 -4
- data/lib/transifex/project_components/language.rb +1 -1
- data/lib/transifex/project_components/language_components/coordinators.rb +4 -6
- data/lib/transifex/project_components/language_components/reviewers.rb +5 -8
- data/lib/transifex/project_components/language_components/translators.rb +6 -9
- data/lib/transifex/project_components/languages.rb +1 -1
- data/lib/transifex/resource.rb +1 -1
- data/lib/transifex/resource_components/content.rb +1 -1
- data/lib/transifex/resource_components/source.rb +1 -1
- data/lib/transifex/resource_components/stats.rb +1 -1
- data/lib/transifex/resource_components/translation.rb +1 -1
- data/lib/transifex/resource_components/translation_components/string.rb +1 -1
- data/lib/transifex/resource_components/translation_components/strings.rb +1 -1
- data/lib/transifex/resources.rb +1 -1
- data/lib/transifex/version.rb +3 -3
- data/spec/cassettes/fetch_formats.yml +121 -0
- data/spec/cassettes/language/fetch_language_info.yml +58 -0
- data/spec/cassettes/language/fetch_languages_info.yml +58 -0
- data/spec/cassettes/project/components/create_language.yml +95 -0
- data/spec/cassettes/project/components/create_language_non_existing_coordinator.yml +48 -0
- data/spec/cassettes/project/components/create_language_without_coordinator.yml +48 -0
- data/spec/cassettes/project/components/fetch_languages.yml +53 -0
- data/spec/cassettes/project/delete_project.yml +108 -0
- data/spec/cassettes/project/fetch_private_project_info.yml +59 -0
- data/spec/cassettes/project/fetch_with_details_private_project_info.yml +66 -0
- data/spec/cassettes/project/language/delete_language.yml +140 -0
- data/spec/cassettes/project/language/fetch_coordinators.yml +56 -0
- data/spec/cassettes/project/language/fetch_language_info.yml +52 -0
- data/spec/cassettes/project/language/fetch_reviewers.yml +56 -0
- data/spec/cassettes/project/language/fetch_translators.yml +54 -0
- data/spec/cassettes/project/language/fetch_with_details_language_info.yml +54 -0
- data/spec/cassettes/project/language/update_coordinators.yml +104 -0
- data/spec/cassettes/project/language/update_language.yml +100 -0
- data/spec/cassettes/project/language/update_non_existing_coordinator.yml +48 -0
- data/spec/cassettes/project/language/update_non_existing_language.yml +49 -0
- data/spec/cassettes/project/language/update_non_existing_reviewer.yml +101 -0
- data/spec/cassettes/project/language/update_non_existing_translator.yml +101 -0
- data/spec/cassettes/project/language/update_reviewers.yml +157 -0
- data/spec/cassettes/project/language/update_translators.yml +157 -0
- data/spec/cassettes/project/update_non_existing_attribute_private_project.yml +54 -0
- data/spec/cassettes/project/update_private_project.yml +120 -0
- data/spec/cassettes/project/update_with_missing_params_private_project.yml +54 -0
- data/spec/cassettes/projects/create_private_project.yml +111 -0
- data/spec/cassettes/projects/create_public_project.yml +111 -0
- data/spec/cassettes/projects/create_used_slug_project.yml +55 -0
- data/spec/cassettes/projects/fetch_projects.yml +61 -0
- data/spec/cassettes/resource/delete_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/delete_resource.yml +160 -0
- data/spec/cassettes/resource/fetch_all_languages_stats.yml +66 -0
- data/spec/cassettes/resource/fetch_content_as_file.yml +56 -0
- data/spec/cassettes/resource/fetch_content_as_hash.yml +58 -0
- data/spec/cassettes/resource/fetch_language_stats.yml +61 -0
- data/spec/cassettes/resource/fetch_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/fetch_resource_info.yml +59 -0
- data/spec/cassettes/resource/fetch_source_string_metadata.yml +52 -0
- data/spec/cassettes/resource/fetch_translations.yml +57 -0
- data/spec/cassettes/resource/fetch_updated_resource_info.yml +60 -0
- data/spec/cassettes/resource/fetch_updated_source_string_metadata.yml +52 -0
- data/spec/cassettes/resource/fetch_with_details_resource_info.yml +65 -0
- data/spec/cassettes/resource/fetch_with_file_and_mode_translations.yml +56 -0
- data/spec/cassettes/resource/fetch_with_file_translations.yml +56 -0
- data/spec/cassettes/resource/update_content_json.yml +115 -0
- data/spec/cassettes/resource/update_content_with_wrong_mimetype.yml +59 -0
- data/spec/cassettes/resource/update_content_yml.yml +114 -0
- data/spec/cassettes/resource/update_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/update_resource_info.yml +114 -0
- data/spec/cassettes/resource/update_source_language.yml +54 -0
- data/spec/cassettes/resource/update_source_string_metadata.yml +100 -0
- data/spec/cassettes/resource/update_translation_for_language.yml +62 -0
- data/spec/cassettes/resources/create_from_file.yml +55 -0
- data/spec/cassettes/resources/create_from_string.yml +54 -0
- data/spec/cassettes/resources/fetch_as_array.yml +62 -0
- data/spec/cassettes/resources/non_existing_project.yml +55 -0
- data/spec/cassettes/translation/fetch_string.yml +55 -0
- data/spec/cassettes/translation/fetch_strings.yml +54 -0
- data/spec/cassettes/translation/fetch_with_details_and_context_strings.yml +51 -0
- data/spec/cassettes/translation/fetch_with_details_and_key_strings.yml +56 -0
- data/spec/cassettes/translation/fetch_with_details_strings.yml +56 -0
- data/spec/cassettes/translation/update_multiple_translation_strings.yml +107 -0
- data/spec/cassettes/translation/update_single_translation_strings.yml +104 -0
- data/spec/cassettes/translation/update_string.yml +104 -0
- data/spec/lib/transifex/coordinators_spec.rb +22 -16
- data/spec/lib/transifex/formats_spec.rb +8 -8
- data/spec/lib/transifex/language_spec.rb +9 -10
- data/spec/lib/transifex/languages_spec.rb +8 -8
- data/spec/lib/transifex/project_language_spec.rb +41 -28
- data/spec/lib/transifex/project_languages_spec.rb +34 -18
- data/spec/lib/transifex/project_spec.rb +46 -73
- data/spec/lib/transifex/projects_spec.rb +72 -37
- data/spec/lib/transifex/resource_content_spec.rb +41 -24
- data/spec/lib/transifex/resource_source_spec.rb +21 -19
- data/spec/lib/transifex/resource_spec.rb +69 -41
- data/spec/lib/transifex/resources_spec.rb +42 -34
- data/spec/lib/transifex/reviewers_spec.rb +23 -17
- data/spec/lib/transifex/stats_spec.rb +20 -24
- data/spec/lib/transifex/translation_spec.rb +60 -38
- data/spec/lib/transifex/translation_string_spec.rb +26 -20
- data/spec/lib/transifex/translation_strings_spec.rb +65 -43
- data/spec/lib/transifex/translators_spec.rb +23 -17
- data/spec/lib/transifex_spec.rb +15 -0
- data/spec/lib/yaml/eo.yml +3 -0
- data/spec/spec_helper.rb +19 -83
- data/spec/support/client_helper.rb +8 -0
- data/spec/support/content_helper.rb +346 -0
- data/transifex-interface-ruby.gemspec +28 -25
- metadata +198 -21
- data/spec/lib/transifex/configuration_spec.rb +0 -17
- data/spec/lib/yaml/resource_translation_default_content_test.yml +0 -4
- data/spec/lib/yaml/resource_translation_reviewed_content_test.yml +0 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
Mjk2ZmY2ZjM3NmE0Y2MyOTA4OGE5Y2FkZmMzMDVhZTk5N2RiNDcyYzhmNDll
|
10
|
-
ZThlODlhMDU2MGZlOGQwMTgxODA3NzdhNjVhOTIxYzU0ZGUzYzFhYWRkOTJk
|
11
|
-
MTAwNTAxOTQ0YTVlYTIyMzliNDAwOGM2NTczYTI2ZmFmZDlhNjE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjBlYWE2ZTI0NjJkMjc5MjM5NmYzNmMyZTg1MmY5NzIwNTJlMTBlMGIyZDY5
|
14
|
-
ODMyNDdmNTBjYjQ0Nzc0OTM3YWQyOGY5NjdkZGQwNTI1Yzk0MzliY2YxMmQy
|
15
|
-
NDRjZjNiMzc5YWI4Y2IwYTI1NjgwMGY1YjRmZDE0YWYxOTUxMWI=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54b9106f9ec2eb907afe6d31b83220b71a029bda
|
4
|
+
data.tar.gz: a9dc02d1e3fb33f07a78f9257b093d1708354f4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0bfbb7d12edea0056a45646b347a34b6fef917d2e92cc7f5a56ced642a9a1ad4a0aed5e5b29b4cb657832252855f3a1a5ca844348eb20800bc6f2280211996a
|
7
|
+
data.tar.gz: 6e2e44980dd82c9258d709ca105351570a32227da83c5143fa0634d6e24ab02774759cc6e3b37c9dc3b81be064372f75065688b25248ee480e5bc94b5fd5eb73
|
data/.gitignore
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in transifex-interface-ruby.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in transifex-interface-ruby.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2014 Fred-grais
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 Fred-grais
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,513 +1,517 @@
|
|
1
|
-
# Transifex::Interface::Ruby
|
2
|
-
|
3
|
-
This gem is designed to interact easily with the Transifex API. You can perform all the actions allowed by the API. Documentation located here : http://docs.transifex.com/developer/api/
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'transifex-interface-ruby'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install transifex-interface-ruby
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
### Initialization
|
22
|
-
|
23
|
-
To initialize the gem, you will have to create an initializer like follow:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
Transifex.configure do |c|
|
27
|
-
c.client_login = 'your_client_login'
|
28
|
-
c.client_secret = 'your_secret'
|
29
|
-
end
|
30
|
-
```
|
31
|
-
Then restart the server.
|
32
|
-
|
33
|
-
If you don't do this you will end up with the following error:
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
#<Transifex::TransifexError: Authorization Required>
|
37
|
-
```
|
38
|
-
|
39
|
-
### Formats
|
40
|
-
|
41
|
-
It represents all the formats available on Transifex:
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
Transifex::Formats.fetch
|
45
|
-
```
|
46
|
-
|
47
|
-
### Languages
|
48
|
-
|
49
|
-
It represents all the languages available on Transifex:
|
50
|
-
|
51
|
-
#### Fetch
|
52
|
-
|
53
|
-
You can fetch all the languages:
|
54
|
-
|
55
|
-
```ruby
|
56
|
-
Transifex::Languages.fetch
|
57
|
-
```
|
58
|
-
|
59
|
-
Or specify a language:
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
Transifex::Languages.fetch('en')
|
63
|
-
```
|
64
|
-
|
65
|
-
### Projects (to fetch all projects and create a new one)
|
66
|
-
|
67
|
-
#### Fetch
|
68
|
-
|
69
|
-
To fetch all the projects owned by the account specified in the initializer:
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
Transifex::Projects.fetch
|
73
|
-
```
|
74
|
-
|
75
|
-
#### Create
|
76
|
-
|
77
|
-
To create a new project, you can proceed as following:
|
78
|
-
|
79
|
-
For a private project:
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
private_project_params = {:slug => "private_project", :name => "Private Project", :description => "description", :source_language_code => "en", :private => true}
|
83
|
-
|
84
|
-
Transifex::Projects.create(private_project_params)
|
85
|
-
```
|
86
|
-
For a public project:
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
public_project_params = {:slug => "public_project", :name => "Public Project", :description => "description", :source_language_code => "en", :repository_url => "http://example.com"}
|
90
|
-
|
91
|
-
Transifex::Projects.create(public_project_params)
|
92
|
-
```
|
93
|
-
|
94
|
-
The complete list of the allowed parameters is located in the Transifex documentation.
|
95
|
-
|
96
|
-
### Project (symbolize an existing project)
|
97
|
-
|
98
|
-
#### Instantiation
|
99
|
-
|
100
|
-
```ruby
|
101
|
-
transifex_project = Transifex::Project.new('project_slug')
|
102
|
-
```
|
103
|
-
or
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
transifex_project = Transifex::Projects.create(params)
|
107
|
-
```
|
108
|
-
#### Fetch
|
109
|
-
|
110
|
-
You can fetch the project informations from transifex:
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
transifex_project_informations = transifex_project.fetch
|
114
|
-
```
|
115
|
-
|
116
|
-
with more details:
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
transifex_project_informations = transifex_project.fetch_with_details
|
120
|
-
```
|
121
|
-
|
122
|
-
#### Update
|
123
|
-
|
124
|
-
You can update the project: (see documentation for available fields)
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
transifex_project.update({:description => "new description"})
|
128
|
-
```
|
129
|
-
#### Destroy
|
130
|
-
|
131
|
-
You can destroy a project:
|
132
|
-
|
133
|
-
```ruby
|
134
|
-
transifex_project.delete
|
135
|
-
```
|
136
|
-
|
137
|
-
### Project Languages ( to fetch all languages of a project and create a new one)
|
138
|
-
|
139
|
-
|
140
|
-
#### Instantiation
|
141
|
-
|
142
|
-
```ruby
|
143
|
-
project_languages = transifex_project.languages
|
144
|
-
```
|
145
|
-
|
146
|
-
#### Fetch
|
147
|
-
|
148
|
-
You can retrieve informations about all the languages of a project:
|
149
|
-
|
150
|
-
```ruby
|
151
|
-
project_languages.fetch
|
152
|
-
```
|
153
|
-
|
154
|
-
#### Create
|
155
|
-
|
156
|
-
You can create a new language for a project:
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
params = {:language_code => "el", :coordinators => ['username']}
|
160
|
-
project_languages.create(params)
|
161
|
-
```
|
162
|
-
|
163
|
-
### Project Language (Symbolize a single language of a project)
|
164
|
-
|
165
|
-
#### Instantiation
|
166
|
-
|
167
|
-
```ruby
|
168
|
-
project_language = transifex_project.language('en')
|
169
|
-
```
|
170
|
-
|
171
|
-
#### Fetch
|
172
|
-
|
173
|
-
You can retrieve informations for a project's specified language:
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
project_language.fetch
|
177
|
-
```
|
178
|
-
|
179
|
-
with details:
|
180
|
-
|
181
|
-
```ruby
|
182
|
-
project_language.fetch_with_details
|
183
|
-
```
|
184
|
-
|
185
|
-
#### Update
|
186
|
-
|
187
|
-
You can update the information of a project's specified language:
|
188
|
-
|
189
|
-
```ruby
|
190
|
-
params = {:coordinators => ['username1', 'username2'], :translators => ['username'], :reviewers => ['username']}
|
191
|
-
project_language.update(params)
|
192
|
-
```
|
193
|
-
|
194
|
-
#### Delete
|
195
|
-
|
196
|
-
You can delete a project's specified language:
|
197
|
-
|
198
|
-
```ruby
|
199
|
-
project_language.delete
|
200
|
-
```
|
201
|
-
|
202
|
-
### Project language management
|
203
|
-
|
204
|
-
You have access to the differents teams of a language: coordinators, reviewers and translators.
|
205
|
-
|
206
|
-
#### Instantiation:
|
207
|
-
|
208
|
-
```ruby
|
209
|
-
project_language_coordinators_team = project_language.coordinators
|
210
|
-
project_language_reviewers_team = project_language.reviewers
|
211
|
-
project_language_translators_team = project_language.translators
|
212
|
-
```
|
213
|
-
|
214
|
-
#### Fetch
|
215
|
-
|
216
|
-
```ruby
|
217
|
-
project_language_xxx_team.fetch
|
218
|
-
```
|
219
|
-
|
220
|
-
#### Update
|
221
|
-
|
222
|
-
```ruby
|
223
|
-
project_language_xxx_team.update(['username1', 'username2'])
|
224
|
-
```
|
225
|
-
|
226
|
-
### Resources ( to fetch all resources of a project and create a new one)
|
227
|
-
|
228
|
-
First, instantiate a project (see Project/instantiation)
|
229
|
-
|
230
|
-
#### Fetch
|
231
|
-
|
232
|
-
You can fetch all the resources of projects:
|
233
|
-
|
234
|
-
```ruby
|
235
|
-
transifex_project.resources
|
236
|
-
```
|
237
|
-
|
238
|
-
#### Create
|
239
|
-
|
240
|
-
You can create a new resource for the specified project:
|
241
|
-
|
242
|
-
Without a file (you have to send the content as a string) :
|
243
|
-
|
244
|
-
```ruby
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
```
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
```
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
```
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
```
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
```
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
```
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
```
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
```
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
```
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
```
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
```
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
```
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
```
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
1
|
+
# Transifex::Interface::Ruby
|
2
|
+
|
3
|
+
This gem is designed to interact easily with the Transifex API. You can perform all the actions allowed by the API. Documentation located here : http://docs.transifex.com/developer/api/
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'transifex-interface-ruby'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install transifex-interface-ruby
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Initialization
|
22
|
+
|
23
|
+
To initialize the gem, you will have to create an initializer like follow:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Transifex.configure do |c|
|
27
|
+
c.client_login = 'your_client_login'
|
28
|
+
c.client_secret = 'your_secret'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
Then restart the server.
|
32
|
+
|
33
|
+
If you don't do this you will end up with the following error:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
#<Transifex::TransifexError: Authorization Required>
|
37
|
+
```
|
38
|
+
|
39
|
+
### Formats
|
40
|
+
|
41
|
+
It represents all the formats available on Transifex:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Transifex::Formats.fetch
|
45
|
+
```
|
46
|
+
|
47
|
+
### Languages
|
48
|
+
|
49
|
+
It represents all the languages available on Transifex:
|
50
|
+
|
51
|
+
#### Fetch
|
52
|
+
|
53
|
+
You can fetch all the languages:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Transifex::Languages.fetch
|
57
|
+
```
|
58
|
+
|
59
|
+
Or specify a language:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Transifex::Languages.fetch('en')
|
63
|
+
```
|
64
|
+
|
65
|
+
### Projects (to fetch all projects and create a new one)
|
66
|
+
|
67
|
+
#### Fetch
|
68
|
+
|
69
|
+
To fetch all the projects owned by the account specified in the initializer:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
Transifex::Projects.fetch
|
73
|
+
```
|
74
|
+
|
75
|
+
#### Create
|
76
|
+
|
77
|
+
To create a new project, you can proceed as following:
|
78
|
+
|
79
|
+
For a private project:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
private_project_params = {:slug => "private_project", :name => "Private Project", :description => "description", :source_language_code => "en", :private => true}
|
83
|
+
|
84
|
+
Transifex::Projects.create(private_project_params)
|
85
|
+
```
|
86
|
+
For a public project:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
public_project_params = {:slug => "public_project", :name => "Public Project", :description => "description", :source_language_code => "en", :repository_url => "http://example.com"}
|
90
|
+
|
91
|
+
Transifex::Projects.create(public_project_params)
|
92
|
+
```
|
93
|
+
|
94
|
+
The complete list of the allowed parameters is located in the Transifex documentation.
|
95
|
+
|
96
|
+
### Project (symbolize an existing project)
|
97
|
+
|
98
|
+
#### Instantiation
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
transifex_project = Transifex::Project.new('project_slug')
|
102
|
+
```
|
103
|
+
or
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
transifex_project = Transifex::Projects.create(params)
|
107
|
+
```
|
108
|
+
#### Fetch
|
109
|
+
|
110
|
+
You can fetch the project informations from transifex:
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
transifex_project_informations = transifex_project.fetch
|
114
|
+
```
|
115
|
+
|
116
|
+
with more details:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
transifex_project_informations = transifex_project.fetch_with_details
|
120
|
+
```
|
121
|
+
|
122
|
+
#### Update
|
123
|
+
|
124
|
+
You can update the project: (see documentation for available fields)
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
transifex_project.update({:description => "new description"})
|
128
|
+
```
|
129
|
+
#### Destroy
|
130
|
+
|
131
|
+
You can destroy a project:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
transifex_project.delete
|
135
|
+
```
|
136
|
+
|
137
|
+
### Project Languages ( to fetch all languages of a project and create a new one)
|
138
|
+
|
139
|
+
|
140
|
+
#### Instantiation
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
project_languages = transifex_project.languages
|
144
|
+
```
|
145
|
+
|
146
|
+
#### Fetch
|
147
|
+
|
148
|
+
You can retrieve informations about all the languages of a project:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
project_languages.fetch
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Create
|
155
|
+
|
156
|
+
You can create a new language for a project:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
params = {:language_code => "el", :coordinators => ['username']}
|
160
|
+
project_languages.create(params)
|
161
|
+
```
|
162
|
+
|
163
|
+
### Project Language (Symbolize a single language of a project)
|
164
|
+
|
165
|
+
#### Instantiation
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
project_language = transifex_project.language('en')
|
169
|
+
```
|
170
|
+
|
171
|
+
#### Fetch
|
172
|
+
|
173
|
+
You can retrieve informations for a project's specified language:
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
project_language.fetch
|
177
|
+
```
|
178
|
+
|
179
|
+
with details:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
project_language.fetch_with_details
|
183
|
+
```
|
184
|
+
|
185
|
+
#### Update
|
186
|
+
|
187
|
+
You can update the information of a project's specified language:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
params = {:coordinators => ['username1', 'username2'], :translators => ['username'], :reviewers => ['username']}
|
191
|
+
project_language.update(params)
|
192
|
+
```
|
193
|
+
|
194
|
+
#### Delete
|
195
|
+
|
196
|
+
You can delete a project's specified language:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
project_language.delete
|
200
|
+
```
|
201
|
+
|
202
|
+
### Project language management
|
203
|
+
|
204
|
+
You have access to the differents teams of a language: coordinators, reviewers and translators.
|
205
|
+
|
206
|
+
#### Instantiation:
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
project_language_coordinators_team = project_language.coordinators
|
210
|
+
project_language_reviewers_team = project_language.reviewers
|
211
|
+
project_language_translators_team = project_language.translators
|
212
|
+
```
|
213
|
+
|
214
|
+
#### Fetch
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
project_language_xxx_team.fetch
|
218
|
+
```
|
219
|
+
|
220
|
+
#### Update
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
project_language_xxx_team.update(['username1', 'username2'])
|
224
|
+
```
|
225
|
+
|
226
|
+
### Resources ( to fetch all resources of a project and create a new one)
|
227
|
+
|
228
|
+
First, instantiate a project (see Project/instantiation)
|
229
|
+
|
230
|
+
#### Fetch
|
231
|
+
|
232
|
+
You can fetch all the resources of projects:
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
transifex_project.resources.fetch
|
236
|
+
```
|
237
|
+
|
238
|
+
#### Create
|
239
|
+
|
240
|
+
You can create a new resource for the specified project:
|
241
|
+
|
242
|
+
Without a file (you have to send the content as a string) :
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
params = {:slug => "resource_slug", :name => "Resource created with content as a string", :i18n_type => "TXT", :content => "test"}
|
246
|
+
transifex_project.resources.create(params)
|
247
|
+
```
|
248
|
+
|
249
|
+
With a file: (YAML currently supported)
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
params = {:slug => "resource_slug", :name => "Resource created with a file", :i18n_type => "YAML", :content => 'path/to/your/file.yml'}
|
253
|
+
options = {:trad_from_file => true}
|
254
|
+
transifex_project.resources.create(params, options)
|
255
|
+
```
|
256
|
+
|
257
|
+
### Resource (Symbolize a single resource of a project)
|
258
|
+
|
259
|
+
#### Instantiation
|
260
|
+
|
261
|
+
You can instantiate a resource as follow:
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
project_resource = transifex_project.resource("resource_slug")
|
265
|
+
```
|
266
|
+
|
267
|
+
#### Fetch
|
268
|
+
|
269
|
+
You can retrieve informations of the specified resource:
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
project_resource.fetch
|
273
|
+
```
|
274
|
+
with more details:
|
275
|
+
|
276
|
+
```ruby
|
277
|
+
project_resource.fetch_with_details
|
278
|
+
```
|
279
|
+
|
280
|
+
#### Update
|
281
|
+
|
282
|
+
You can update a resource: (see documentation for allowed fields)
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
project_resource.update({name: "new_name", categories: ["cat1", "cat2"]})
|
286
|
+
```
|
287
|
+
|
288
|
+
#### Delete
|
289
|
+
|
290
|
+
You can delete the specified resource:
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
project_resource.delete
|
294
|
+
```
|
295
|
+
|
296
|
+
### Resource Content ( Source language content)
|
297
|
+
|
298
|
+
You can manage the resource's source language
|
299
|
+
|
300
|
+
#### Fetch
|
301
|
+
|
302
|
+
You can retrieve the source language content:
|
303
|
+
|
304
|
+
As a hash: (content is encoded as a string)
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
project_resource.content.fetch
|
308
|
+
```
|
309
|
+
|
310
|
+
Or as a file
|
311
|
+
Here for a YAML file:
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
project_resource.content.fetch_with_file("path/where/file/will/be/saved.yml")
|
315
|
+
```
|
316
|
+
The source language content will be copied in the specified file.
|
317
|
+
|
318
|
+
#### Update
|
319
|
+
|
320
|
+
You can update the source language content (add new traductions for example):
|
321
|
+
Attention: the source language content will be overrided.
|
322
|
+
|
323
|
+
You must update the source language content with the same method used to create the resource.
|
324
|
+
|
325
|
+
So if you used a YAML file, you must provide a new YAML file.
|
326
|
+
|
327
|
+
With the content as a string:
|
328
|
+
|
329
|
+
```ruby
|
330
|
+
project_resource.content.update({:i18n_type => "TXT", :content => 'new_content'})
|
331
|
+
```
|
332
|
+
|
333
|
+
With a file:
|
334
|
+
|
335
|
+
```ruby
|
336
|
+
params = {:i18n_type => "YAML", :content => 'path/to/your/file.yml'}
|
337
|
+
options = {:trad_from_file => true}
|
338
|
+
project_resource.content.update(params, options)
|
339
|
+
```
|
340
|
+
|
341
|
+
### Resource Translations
|
342
|
+
|
343
|
+
The following will explain how you can fetch the different translations of a resource and update them.
|
344
|
+
|
345
|
+
You have to specify the language you want to work on.
|
346
|
+
For example to work on the english translation:
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
resource_translation = project_resource.translation('en')
|
350
|
+
```
|
351
|
+
|
352
|
+
#### Fetch
|
353
|
+
|
354
|
+
You can fetch the translation content of a resource:
|
355
|
+
|
356
|
+
As a Hash: (content encoded as a string)
|
357
|
+
|
358
|
+
```ruby
|
359
|
+
resource_translation.fetch
|
360
|
+
```
|
361
|
+
|
362
|
+
As a file: (file saved to the specified location)
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
options = {:path_to_file => path_to_file}
|
366
|
+
resource_translation.fetch_with_file(options)
|
367
|
+
```
|
368
|
+
|
369
|
+
You can use some options (as defined in the transifex documentations)
|
370
|
+
|
371
|
+
For example to retrieve only reviewed translations:
|
372
|
+
|
373
|
+
```ruby
|
374
|
+
options = {:path_to_file => path_to_file, :mode => "reviewed"}
|
375
|
+
resource_translation.fetch_with_file(options)
|
376
|
+
```
|
377
|
+
|
378
|
+
#### Update
|
379
|
+
|
380
|
+
You can update the translation content:
|
381
|
+
|
382
|
+
```ruby
|
383
|
+
options = {:i18n_type => "YAML", :content => "/path/to/the/file/to/upload.yml"}
|
384
|
+
resource_translation.update(options)
|
385
|
+
```
|
386
|
+
|
387
|
+
### Resource Translations Strings
|
388
|
+
|
389
|
+
Resource translations strings allow you to retrieve meta-informations about translations strings (translation key, context, content, and so on)
|
390
|
+
|
391
|
+
#### Instantiation
|
392
|
+
|
393
|
+
```ruby
|
394
|
+
resource_translation_strings = resource_translation.strings
|
395
|
+
```
|
396
|
+
|
397
|
+
#### Fetch
|
398
|
+
|
399
|
+
You can fetch informations of all the strings of a translation:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
resource_translation_strings.fetch
|
403
|
+
```
|
404
|
+
|
405
|
+
With details:
|
406
|
+
|
407
|
+
```ruby
|
408
|
+
resource_translation_strings.fetch_with_details
|
409
|
+
```
|
410
|
+
|
411
|
+
You can specify a key and/or a context to search a particular string
|
412
|
+
|
413
|
+
```ruby
|
414
|
+
options = {:key => "welcome", :context => "context"}
|
415
|
+
resource_translation_strings.fetch_with_details(options)
|
416
|
+
```
|
417
|
+
|
418
|
+
#### Update
|
419
|
+
|
420
|
+
You can update some informations of a translation string (see documentation for available fields):
|
421
|
+
|
422
|
+
You must specify at least the key of the translation, and can add a context(by default empty).
|
423
|
+
|
424
|
+
```ruby
|
425
|
+
params = {:key => "welcome", :context => "", :translation => "new_translation"}
|
426
|
+
resource_translation_strings.update(params)
|
427
|
+
```
|
428
|
+
### Resource Translations String (Symbolize a single string)
|
429
|
+
|
430
|
+
#### Instantiation
|
431
|
+
|
432
|
+
Context is empty by default.
|
433
|
+
|
434
|
+
```ruby
|
435
|
+
resource_translation_string = resource_translation.string(key, context)
|
436
|
+
```
|
437
|
+
|
438
|
+
#### Fetch
|
439
|
+
|
440
|
+
You can fetch the informations about the specified string:
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
resource_translation_string.fetch
|
444
|
+
```
|
445
|
+
|
446
|
+
#### Update
|
447
|
+
|
448
|
+
You can update the informations of the specified string: (available fields in the documentation)
|
449
|
+
|
450
|
+
```ruby
|
451
|
+
params = {:reviewed => true, :translation => "new translation"}
|
452
|
+
resource_translation_string.update(params)
|
453
|
+
```
|
454
|
+
|
455
|
+
### Resource Source String
|
456
|
+
|
457
|
+
It allow you to retrieve meta-data on a source language string and update them.
|
458
|
+
|
459
|
+
#### Instantiation
|
460
|
+
|
461
|
+
Context is empty by default.
|
462
|
+
|
463
|
+
```ruby
|
464
|
+
resource_source_string = project_resource.source('key', 'context')
|
465
|
+
```
|
466
|
+
|
467
|
+
#### Fetch
|
468
|
+
|
469
|
+
You can fetch meta-data about the specified source string:
|
470
|
+
|
471
|
+
```ruby
|
472
|
+
resource_source_string.fetch
|
473
|
+
```
|
474
|
+
|
475
|
+
#### Update
|
476
|
+
|
477
|
+
You can update the meta-data of the specified source string
|
478
|
+
|
479
|
+
```ruby
|
480
|
+
params = {:comment => "my comment", :character_limit => 140, :tags => ["tag1", "tag2"]}
|
481
|
+
resource_source_string.update(params)
|
482
|
+
```
|
483
|
+
|
484
|
+
### Resource Statistics
|
485
|
+
|
486
|
+
It allow you to retrieve some transifex stats about a resource.
|
487
|
+
|
488
|
+
#### Instantiation
|
489
|
+
|
490
|
+
```ruby
|
491
|
+
resource_stats = project_resource.statistics
|
492
|
+
```
|
493
|
+
|
494
|
+
#### Fetch
|
495
|
+
|
496
|
+
You can fetch the statistics:
|
497
|
+
|
498
|
+
Of all the the resource languages:
|
499
|
+
|
500
|
+
```ruby
|
501
|
+
resource_stats.fetch
|
502
|
+
```
|
503
|
+
|
504
|
+
Of a specified language:
|
505
|
+
|
506
|
+
```ruby
|
507
|
+
resource_stats.fetch('en')
|
508
|
+
```
|
509
|
+
|
510
|
+
|
511
|
+
## Contributing
|
512
|
+
|
513
|
+
1. Fork it
|
514
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
515
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
516
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
517
|
+
5. Create new Pull Request
|