yatapp 0.5.2 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 401283e7da3d120b0c443af81eb7bfb45ab0c0d0
4
- data.tar.gz: c77d8887d5e7e339a34169b8dafa62b2087cd558
3
+ metadata.gz: b12a1257b937f74da0bf2c3f18e3bc7ea21e1dbc
4
+ data.tar.gz: 31e98c114fc12650211a608426fbf455c5fe76d0
5
5
  SHA512:
6
- metadata.gz: 347e3529cc7fbd21a695167a384232d60a75b3f6f558ab0398ee64f6e5cb2a8c59453ff8070fd368026488f180d5c84c8dcc6f6aedaf36a9e3aa34c047633109
7
- data.tar.gz: 8fea501d16fa9524e034de8e6f7bfba7cf158824d5538df33988819ac377dec4a727f169d88f020bf04099f4221b5d9a3fc0df99c1a703d4d7b3e7f9b20ff8a9
6
+ metadata.gz: 77b77d31c68566ca619acee60bd423703bf5f0005a0afdd7b0b917e831cedd48a3e68c0ed82daf3aec5d968652bcf22eb129f2e2dfa51e308f16056c4a3607b4
7
+ data.tar.gz: d3306498e3ac160adb1f51c9964cd2aab520013aa2efaf474d4941141bd2e24dd4efcd940aa6b6cbe354cb198367104a80f158ff428e770c209b745fc73d7e91
data/README.md CHANGED
@@ -32,6 +32,7 @@ Gem can be used in two ways:
32
32
  * `translation_format` - format you wish to get files in, available for now are (yaml, js, json, properties, xml, strings and plist). Default: `json`
33
33
  * `save_to_path` - you can define where files should be saved. Default: `/config/locales/`
34
34
  * `root` - add locale as root to file with translations. Default: `false`
35
+ * `strip_empty` - generates only keys that have text and skip empty ones. Default `false`
35
36
 
36
37
  First two parameters are required and the rest is optional.
37
38
 
@@ -55,7 +56,9 @@ Translations with root set to `true`:
55
56
 
56
57
  ### API Integration
57
58
 
58
- Recommended configuration:
59
+ #### Rails
60
+
61
+ Recommended configuration for Rails applications:
59
62
 
60
63
  ```ruby
61
64
  # config/initializers/yatapp.rb
@@ -66,28 +69,29 @@ Yatapp.configure do |c|
66
69
  c.api_access_token = ENV['YATA_API_KEY']
67
70
  c.project_id = ENV['YATA_PROJECT_ID']
68
71
  c.languages = ['en', 'de', 'en_US']
69
- c.translations_format = 'json'
72
+ c.translation_format = 'json'
70
73
  end
71
74
  ```
72
75
 
73
76
  To save file in a different location from default or add a locale as a root, add to configuration two lines as in example below:
74
77
 
75
78
  ```ruby
76
- # config/initializers/yatapp.rb
77
-
78
- include Yatapp
79
-
80
- Yatapp.configure do |c|
81
- c.api_access_token = ENV['YATA_API_KEY']
82
- c.project_id = ENV['YATA_PROJECT_ID']
83
- c.languages = ['en', 'de', 'en_US']
84
- c.translations_format = 'json'
85
- c.save_to_path = '/public/locales/'
86
- c.root = true
87
- end
79
+ # config/initializers/yatapp.rb
80
+
81
+ include Yatapp
82
+
83
+ Yatapp.configure do |c|
84
+ c.api_access_token = ENV['YATA_API_KEY']
85
+ c.project_id = ENV['YATA_PROJECT_ID']
86
+ c.languages = ['en', 'de', 'en_US']
87
+ c.translation_format = 'json'
88
+ c.save_to_path = '/public/locales/'
89
+ c.root = true
90
+ c.strip_empty = true
91
+ end
88
92
  ```
89
93
 
90
- From now on your translations will be saved in `/public/locales/` directory and translations will have locale as a root.
94
+ From now on your translations will be saved in `/public/locales/` directory, translations will have locale as a root and all keys without text will be skipped.
91
95
 
92
96
 
93
97
  API integration allows you to download all translations using rake task:
@@ -96,6 +100,41 @@ API integration allows you to download all translations using rake task:
96
100
  $ rake yata:fetch_translations
97
101
  ```
98
102
 
103
+ #### Sinatra
104
+
105
+ Add to your Gemfile `yatapp` gem:
106
+
107
+ ```ruby
108
+ # Gemfile
109
+
110
+ gem 'yatapp'
111
+ ```
112
+
113
+ Install with `bundle install`.
114
+
115
+ Add Rakefile file in root of your project with custom task:
116
+
117
+ ```ruby
118
+ # Rakefile
119
+
120
+ require 'yatapp'
121
+ require 'sinatra'
122
+
123
+ Yatapp.configure do |c|
124
+ c.api_access_token = ENV['YATA_API_KEY']
125
+ c.project_id = ENV['YATA_PROJECT_ID']
126
+ c.languages = ['en', 'de', 'en_US']
127
+ c.translation_format = 'json'
128
+ c.save_to_path = Sinatra::Application.settings.root + '/config/locales/'
129
+ end
130
+
131
+ task :fetch_translations do
132
+ Yatapp.get_translations
133
+ end
134
+ ```
135
+
136
+ From now on your translations can be fetched with command: `rake fetch_translations`
137
+
99
138
  ### Websocket Integration
100
139
 
101
140
  Websocket integration connects to Yata server and stays open. All changes in translations are auto-fetched to the app.
@@ -7,7 +7,8 @@ module Yatapp
7
7
  :languages,
8
8
  :translation_format,
9
9
  :root,
10
- :save_to_path
10
+ :save_to_path,
11
+ :strip_empty
11
12
  ].freeze
12
13
 
13
14
  attr_accessor *CONFIGURATION_OPTIONS
@@ -1,3 +1,3 @@
1
1
  module Yatapp
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -9,11 +9,12 @@ module Yatapp
9
9
  attr_accessor *Yatapp::Configuration::CONFIGURATION_OPTIONS
10
10
 
11
11
  def initialize
12
- @translation_format = 'json'
13
- @save_to_path = ""
14
- @root = false
15
- @languages = ['en']
16
12
  initialize_configuration
13
+ @translation_format ||= 'json'
14
+ @save_to_path ||= ""
15
+ @root ||= false
16
+ @languages ||= ['en']
17
+ @strip_empty ||= false
17
18
  end
18
19
 
19
20
  def get_translations
@@ -73,7 +74,7 @@ module Yatapp
73
74
  url = url.sub(':format', translation_format)
74
75
  url = url.sub(':api_version', API_VERSION)
75
76
  url = url.sub(':lang', lang)
76
- url = url + "?apiToken=#{api_access_token}&root=#{root}"
77
+ url = url + "?apiToken=#{api_access_token}&root=#{root}&strip_empty=#{strip_empty}"
77
78
  end
78
79
 
79
80
  def download_url_websocket(lang)
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'faye-websocket'
31
31
  spec.add_dependency 'rails-i18n'
32
32
  spec.add_dependency 'httparty'
33
+ spec.add_dependency 'rake'
34
+
33
35
  spec.add_development_dependency "bundler", "~> 1.16"
34
36
  spec.add_development_dependency "pry"
35
37
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yatapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - luki3k5
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement