translation 1.13 → 1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +97 -61
- data/lib/translation_io/client/base_operation.rb +2 -1
- data/lib/translation_io/client/sync_operation.rb +2 -2
- data/lib/translation_io/tasks.rb +4 -4
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23364df129fca187e3e946e7e9630262c688095d
|
4
|
+
data.tar.gz: 879857716430eac90526ba693bbcb5a2610a8959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47bebb33125a5f88741b3e073968fa457ac94ebfe6780e38949b97cd64ad455cdc7df103fe7e95b74b5c9a934180d6b8ee2161f797f95c321fcedd223c53affc
|
7
|
+
data.tar.gz: 4d17d4bca46162e0835129a293c9e80f69fa9df5239ca5b56dcb3b06a8de9ae479c3df9085599c4b2f5a9a56dd2deb8eb3bc421d9e96d32069ff6cc1b318ebe7
|
data/README.md
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# [Translation.io](https://translation.io) client for Ruby on Rails
|
2
2
|
|
3
|
-
|
4
|
-
[
|
3
|
+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
|
4
|
+
[![Codeship Status](https://app.codeship.com/projects/f7cd4ac0-b73c-0131-51ea-522dcd2196ed/status?branch=master)](https://app.codeship.com/projects/20528)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/aurels/translation-gem/badges/coverage.svg)](https://codeclimate.com/github/aurels/translation-gem/coverage)
|
6
|
+
|
7
|
+
Add this gem to translate your application with [I18n (YAML)](#i18n-yaml) or
|
8
|
+
[GetText](#gettext) syntaxes.
|
5
9
|
|
6
10
|
Keep it synchronized with your translators on [Translation.io](https://translation.io).
|
7
11
|
|
8
|
-
[![Image](https://
|
12
|
+
[![Image](https://translation.io/interface.png)](https://translation.io)
|
9
13
|
|
10
14
|
Need help? [contact@translation.io](mailto:contact@translation.io)
|
11
15
|
|
12
16
|
Table of contents
|
13
17
|
=================
|
14
18
|
|
15
|
-
* [Installation](#installation)
|
16
19
|
* [Translation syntaxes](#translation-syntaxes)
|
17
20
|
* [I18n (YAML)](#i18n-yaml)
|
18
21
|
* [GetText](#gettext)
|
22
|
+
* [Installation](#installation)
|
19
23
|
* [Usage](#usage)
|
20
24
|
* [Sync](#sync)
|
21
25
|
* [Sync and Show Purgeable](#sync-and-show-purgeable)
|
@@ -27,39 +31,14 @@ Table of contents
|
|
27
31
|
* [Custom localization key prefixes](#custom-localization-key-prefixes)
|
28
32
|
* [Paths where locales are stored (not recommended)](#paths-where-locales-are-stored-not-recommended)
|
29
33
|
* [Pure Ruby (without Rails)](#pure-ruby-without-rails)
|
30
|
-
* [
|
31
|
-
* [
|
34
|
+
* [List of clients for Translation.io](#list-of-clients-for-translationio)
|
35
|
+
* [Ruby on Rails (Ruby)](#ruby-on-rails-ruby)
|
32
36
|
* [Laravel (PHP)](#laravel-php)
|
33
|
-
|
37
|
+
* [React and React-Intl (JavaScript)](#react-and-react-intl-javascript)
|
38
|
+
* [Testing](#testing)
|
34
39
|
* [Contributing](#contributing)
|
35
40
|
* [Credits](#credits)
|
36
41
|
|
37
|
-
## Installation
|
38
|
-
|
39
|
-
1. Add the gem to your project's Gemfile:
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
gem 'translation'
|
43
|
-
```
|
44
|
-
|
45
|
-
2. Create a new translation project [from the UI](https://translation.io).
|
46
|
-
3. Copy the initializer into your Rails app (`config/initializers/translation.rb`)
|
47
|
-
|
48
|
-
The initializer looks like this:
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
TranslationIO.configure do |config|
|
52
|
-
config.api_key = 'abcdefghijklmnopqrstuvwxyz012345'
|
53
|
-
config.source_locale = 'en'
|
54
|
-
config.target_locales = ['fr', 'nl', 'de', 'es']
|
55
|
-
end
|
56
|
-
```
|
57
|
-
|
58
|
-
4. Initialize your translation project with `bundle exec rake translation:init`
|
59
|
-
|
60
|
-
If you later need to add/remove target languages, please read our
|
61
|
-
[documentation](https://translation.io/blog/adding-target-languages) about that.
|
62
|
-
|
63
42
|
## Translation syntaxes
|
64
43
|
|
65
44
|
#### I18n (YAML)
|
@@ -70,19 +49,19 @@ The default [Rails Internationalization API](http://guides.rubyonrails.org/i18n.
|
|
70
49
|
# Regular
|
71
50
|
t('inbox.title')
|
72
51
|
|
73
|
-
#
|
52
|
+
# Pluralization
|
74
53
|
t('inbox.message', count: n)
|
75
54
|
|
76
55
|
# Interpolation
|
77
56
|
t('inbox.hello', name: @user.name)
|
78
57
|
```
|
79
58
|
|
80
|
-
|
59
|
+
With the source YAML file:
|
81
60
|
|
82
61
|
```yaml
|
83
62
|
en:
|
84
63
|
inbox:
|
85
|
-
title: '
|
64
|
+
title: 'Title to be translated'
|
86
65
|
message:
|
87
66
|
zero: 'no messages'
|
88
67
|
one: 'one message'
|
@@ -99,36 +78,73 @@ that you use GetText to translate your applications since it allows a simpler an
|
|
99
78
|
|
100
79
|
```ruby
|
101
80
|
# Regular
|
102
|
-
_("
|
81
|
+
_("Text to be translated")
|
103
82
|
|
104
|
-
#
|
105
|
-
n_("
|
83
|
+
# Pluralization
|
84
|
+
n_("Singular text", "Plural text", number)
|
106
85
|
|
107
86
|
# Regular with context
|
108
|
-
p_("context", "
|
87
|
+
p_("context", "Text to be translated")
|
109
88
|
|
110
|
-
#
|
111
|
-
np_("context", "
|
89
|
+
# Pluralization with context
|
90
|
+
np_("context", "Singular text", "Plural text", number)
|
112
91
|
|
113
92
|
# Interpolations
|
114
93
|
_('%{city1} is bigger than %{city2}') % { city1: "NYC", city2: "BXL" }
|
115
94
|
```
|
116
95
|
|
96
|
+
You don't need another file with source text or translations, everything will
|
97
|
+
be synchronized from Translation.io, and stored on PO/MO files.
|
98
|
+
|
117
99
|
More information about GetText syntax [here](https://github.com/ruby-gettext/gettext#usage).
|
118
100
|
|
101
|
+
## Installation
|
102
|
+
|
103
|
+
1. Add the gem to your project's Gemfile:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
gem 'translation'
|
107
|
+
```
|
108
|
+
|
109
|
+
2. Create a new translation project [from the UI](https://translation.io).
|
110
|
+
3. Copy the initializer into your Rails app (`config/initializers/translation.rb`)
|
111
|
+
|
112
|
+
The initializer looks like this:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
TranslationIO.configure do |config|
|
116
|
+
config.api_key = 'abcdefghijklmnopqrstuvwxyz012345'
|
117
|
+
config.source_locale = 'en'
|
118
|
+
config.target_locales = ['fr', 'nl', 'de', 'es']
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
4. Initialize your project and push existing translations to Translation.io with:
|
123
|
+
|
124
|
+
```bash
|
125
|
+
$ bundle exec rake translation:init
|
126
|
+
```
|
127
|
+
|
128
|
+
If you later need to add/remove target languages, please read our
|
129
|
+
[documentation](https://translation.io/blog/adding-target-languages) about that.
|
130
|
+
|
119
131
|
## Usage
|
120
132
|
|
121
133
|
#### Sync
|
122
134
|
|
123
135
|
To send new translatable keys/strings and get new translations from Translation.io, simply run:
|
124
136
|
|
125
|
-
|
137
|
+
```bash
|
138
|
+
$ bundle exec rake translation:sync
|
139
|
+
```
|
126
140
|
|
127
141
|
#### Sync and Show Purgeable
|
128
142
|
|
129
|
-
If you need to
|
143
|
+
If you need to find out what are the unused keys/strings from Translation.io, using the current branch as reference:
|
130
144
|
|
131
|
-
|
145
|
+
```bash
|
146
|
+
$ bundle exec rake translation:sync_and_show_purgeable
|
147
|
+
```
|
132
148
|
|
133
149
|
As the name says, this operation will also perform a sync at the same time.
|
134
150
|
|
@@ -136,7 +152,9 @@ As the name says, this operation will also perform a sync at the same time.
|
|
136
152
|
|
137
153
|
If you need to remove unused keys/strings from Translation.io, using the current branch as reference:
|
138
154
|
|
139
|
-
|
155
|
+
```bash
|
156
|
+
$ bundle exec rake translation:sync_and_purge
|
157
|
+
```
|
140
158
|
|
141
159
|
As the name says, this operation will also perform a sync at the same time.
|
142
160
|
|
@@ -301,40 +319,58 @@ This gem was created specifically for Rails, but you can also use it in a pure R
|
|
301
319
|
|
302
320
|
(Thanks [@kubaw](https://github.com/kubaw) for this snippet!)
|
303
321
|
|
304
|
-
##
|
322
|
+
## List of clients for Translation.io
|
305
323
|
|
306
|
-
These implementations
|
307
|
-
|
324
|
+
These implementations were usually started by contributors for their own projects.
|
325
|
+
Some of them are officially supported by [Translation.io](https://translation.io)
|
326
|
+
and some are not yet supported. However, they are quite well documented.
|
308
327
|
|
309
328
|
Thanks a lot to these contributors for their hard work!
|
310
329
|
|
311
|
-
|
330
|
+
If you want to create a new client for your favorite language or framework, feel
|
331
|
+
free to reach us on [contact@translation.io](mailto:contact@translation.io) and
|
332
|
+
we'll assist you with the workflow logic and send you API docs.
|
312
333
|
|
313
|
-
|
314
|
-
|
334
|
+
#### Ruby on Rails (Ruby)
|
335
|
+
|
336
|
+
Officially Supported on [https://translation.io/rails](https://translation.io/rails)
|
315
337
|
|
316
|
-
|
338
|
+
* GitHub: https://github.com/aurels/translation-gem
|
339
|
+
* RubyGems: https://rubygems.org/gems/translation/
|
340
|
+
|
341
|
+
Credits: [@aurels](https://github.com/aurels), [@michaelhoste](https://github.com/michaelhoste)
|
317
342
|
|
318
343
|
#### Laravel (PHP)
|
319
344
|
|
320
|
-
|
321
|
-
|
345
|
+
Officially Supported on [https://translation.io/laravel](https://translation.io/laravel)
|
346
|
+
|
347
|
+
* GitHub: https://github.com/translation/laravel
|
348
|
+
* Packagist: https://packagist.org/packages/tio/laravel
|
322
349
|
|
323
|
-
|
350
|
+
Credits: [@armandsar](https://github.com/armandsar), [@michaelhoste](https://github.com/michaelhoste)
|
324
351
|
|
325
|
-
|
352
|
+
#### React and React-Intl (JavaScript)
|
353
|
+
|
354
|
+
* GitHub: https://github.com/deecewan/translation-io
|
355
|
+
* NPM: https://www.npmjs.com/package/translation-io
|
356
|
+
|
357
|
+
Credits: [@deecewan](https://github.com/deecewan)
|
358
|
+
|
359
|
+
## Testing
|
326
360
|
|
327
361
|
To run the specs:
|
328
362
|
|
329
|
-
|
363
|
+
```bash
|
364
|
+
$ bundle exec rspec
|
365
|
+
```
|
330
366
|
|
331
367
|
## Contributing
|
332
368
|
|
333
|
-
Please read the [CONTRIBUTING](
|
369
|
+
Please read the [CONTRIBUTING](CONTRIBUTING.md) file.
|
334
370
|
|
335
371
|
## Credits
|
336
372
|
|
337
373
|
The [translation gem](https://rubygems.org/gems/translation) in released under MIT license by
|
338
|
-
[Aurélien Malisart](http://aurelien.malisart.be) and [Michaël Hoste](
|
374
|
+
[Aurélien Malisart](http://aurelien.malisart.be) and [Michaël Hoste](https://80limit.com) (see [LICENSE](LICENSE) file).
|
339
375
|
|
340
376
|
(c) [https://translation.io](https://translation.io) / [contact@translation.io](mailto:contact@translation.io)
|
@@ -20,7 +20,8 @@ module TranslationIO
|
|
20
20
|
def self.perform_request(uri, params)
|
21
21
|
begin
|
22
22
|
params.merge!({
|
23
|
-
'
|
23
|
+
'client' => 'rails',
|
24
|
+
'version' => TranslationIO.version,
|
24
25
|
'source_language' => TranslationIO.config.source_locale.to_s,
|
25
26
|
'target_languages[]' => TranslationIO.config.target_locales.map(&:to_s)
|
26
27
|
})
|
@@ -65,7 +65,7 @@ module TranslationIO
|
|
65
65
|
puts
|
66
66
|
puts "----------"
|
67
67
|
puts "#{yaml_size + gettext_size} keys/strings are in Translation.io but not in your current branch."
|
68
|
-
puts 'Execute "rake translation:sync_and_show_purgeable" to list these keys/strings'
|
68
|
+
puts 'Execute "rake translation:sync_and_show_purgeable" to list these keys/strings.'
|
69
69
|
end
|
70
70
|
# Complete summary for sync_and_show_purgeable or sync_and_purge
|
71
71
|
else
|
@@ -108,7 +108,7 @@ module TranslationIO
|
|
108
108
|
if show_purgeable && total_size > 0
|
109
109
|
puts
|
110
110
|
puts "----------"
|
111
|
-
puts "If you know what you are doing, you can remove them using \"rake translation:sync_and_purge\""
|
111
|
+
puts "If you know what you are doing, you can remove them using \"rake translation:sync_and_purge\"."
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
data/lib/translation_io/tasks.rb
CHANGED
@@ -5,12 +5,12 @@ require 'gettext/tools'
|
|
5
5
|
|
6
6
|
namespace :translation do
|
7
7
|
|
8
|
-
desc "Get configuration infos of Translation gem"
|
8
|
+
desc "Get configuration infos of Translation gem."
|
9
9
|
task :config => :environment do
|
10
10
|
puts TranslationIO.config
|
11
11
|
end
|
12
12
|
|
13
|
-
desc "Initialize
|
13
|
+
desc "Initialize Translation.io with existing keys/strings."
|
14
14
|
task :init => :environment do
|
15
15
|
if client_ready?
|
16
16
|
TranslationIO.client.init
|
@@ -24,14 +24,14 @@ namespace :translation do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
desc "Sync and
|
27
|
+
desc "Sync translations and find out the unused keys/string from Translation.io, using the current branch as reference."
|
28
28
|
task :sync_and_show_purgeable => :environment do
|
29
29
|
if client_ready?
|
30
30
|
TranslationIO.client.sync_and_show_purgeable
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
desc "Sync and remove unused keys
|
34
|
+
desc "Sync translations and remove unused keys from Translation.io, using the current branch as reference."
|
35
35
|
task :sync_and_purge => :environment do
|
36
36
|
if client_ready?
|
37
37
|
TranslationIO.client.sync_and_purge
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.14'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurelien Malisart
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|
@@ -95,9 +95,8 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 1.0.0
|
98
|
-
description:
|
99
|
-
|
100
|
-
synchronize with your translators.
|
98
|
+
description: Localize your app using either t(".keys") or _("source text") and type
|
99
|
+
"rake translation:sync" to synchronize with your translators on Translation.io.
|
101
100
|
email: contact@translation.io
|
102
101
|
executables: []
|
103
102
|
extensions: []
|
@@ -151,5 +150,5 @@ rubyforge_project:
|
|
151
150
|
rubygems_version: 2.4.5
|
152
151
|
signing_key:
|
153
152
|
specification_version: 4
|
154
|
-
summary: Rails translation made _("simple") with YAML and GetText.
|
153
|
+
summary: Rails translation made _("simple") with YAML and GetText using Translation.io.
|
155
154
|
test_files: []
|