ad_localize 4.1.1 → 5.0.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: 1971516fa956f4228c8a1c7e8d3b06e635ef6a6e609d784af4596d3d84761d1c
4
- data.tar.gz: 63b3fd447704657f10b76485710ceb75a5b945b92b8c40eb5f3c16e5466b381b
3
+ metadata.gz: e367d46040937d12da9dabf34045b83a66a3e3a042833f96971c84621f326ff7
4
+ data.tar.gz: d6939a29627f1c1681525c5618dd2f68e78132de0d75d3208ad53c8495c346d3
5
5
  SHA512:
6
- metadata.gz: 7e34444bd5440e40fd667b6a904c6871382bffc74461011801e120dd95380c256b42f4ed61dc740695805819abe137294b5071446a158e82e27090fa747c7a19
7
- data.tar.gz: a062eac8f10ba7f2e3a85d88ee9f02c5f9b1c8fde4de560155c517e69b63010da6d7113c14f18c7e635a0831839ae0a66aacd74ba756ff8c6c5b1d813c892e8a
6
+ metadata.gz: d05c3855c3a3b1de045b7f808d8e7e1898ba6f1a65e27cb9cd1788578ae4c448abb6960b450a09c43416b8744c6ec8857b936889111ca10553daf17771b40692
7
+ data.tar.gz: c52f9eee3bab2dd91b8786ff6eb848c9da3b3ef3e0a9a3bccf0445783118432be8538ac3a12ef6639831ab920df37b98c7e8cbee0cbdf595a4e475e419a70261
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: ['2.6.6', '2.7.3', '3.0.1']
10
+ ruby: ['2.7.3', '3.0.1', '3.1.0']
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## Unreleased
9
+
10
+ ## [5.0.0] - 2022-07-26
11
+
12
+ ### Added
13
+
14
+ - Added new option (-x) to bypass keys with empty values for iOS only in
15
+ PR [#78](https://github.com/faberNovel/ad_localize/pull/78) by [ThomasEsterlin](https://github.com/ThomasEsterlin)
16
+
17
+ ### Breaking change
18
+
19
+ - Drop support for Ruby >= 2.3, < 2.7
20
+
8
21
  ## [4.1.1] - 2022-04-15
9
22
 
10
23
  ### Fixed
@@ -21,10 +34,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
34
 
22
35
  ### Fixed
23
36
 
24
- - Fix error warning when spreadsheet is empty. Fix [#58](https://github.com/applidium/ad_localize/issues/58) in PR [#69](https://github.com/applidium/ad_localize/pull/69)
25
- - Add warning messages when input is corrupted. Fix [#59](https://github.com/applidium/ad_localize/issues/59) in PR [#69](https://github.com/applidium/ad_localize/pull/69)
26
- - Fix performance issue and add warning messages. Fix [#61](https://github.com/applidium/ad_localize/issues/61) in PR [#69](https://github.com/applidium/ad_localize/pull/69)
27
- - Update deprecated `google-api-client` gem. Fix [#63](https://github.com/applidium/ad_localize/issues/63) in PR [#70](https://github.com/applidium/ad_localize/pull/70)
37
+ - Fix error warning when spreadsheet is empty. Fix [#58](https://github.com/applidium/ad_localize/issues/58) in
38
+ PR [#69](https://github.com/applidium/ad_localize/pull/69)
39
+ - Add warning messages when input is corrupted. Fix [#59](https://github.com/applidium/ad_localize/issues/59) in
40
+ PR [#69](https://github.com/applidium/ad_localize/pull/69)
41
+ - Fix performance issue and add warning messages. Fix [#61](https://github.com/applidium/ad_localize/issues/61) in
42
+ PR [#69](https://github.com/applidium/ad_localize/pull/69)
43
+ - Update deprecated `google-api-client` gem. Fix [#63](https://github.com/applidium/ad_localize/issues/63) in
44
+ PR [#70](https://github.com/applidium/ad_localize/pull/70)
28
45
 
29
46
  ## [4.0.8] - 2021-05-25
30
47
 
@@ -72,7 +89,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
72
89
 
73
90
  ### Fixed
74
91
 
75
- - Use percent HTML char for escaping '%' on android. [#49](https://github.com/applidium/ad_localize/pull/49) by [flolom](https://github.com/flolom)
92
+ - Use percent HTML char for escaping '%' on android. [#49](https://github.com/applidium/ad_localize/pull/49)
93
+ by [flolom](https://github.com/flolom)
76
94
 
77
95
  ## [4.0.1] - 2020-10-19
78
96
 
@@ -85,8 +103,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
85
103
  ### Breaking change
86
104
 
87
105
  - Precedence to csv files. Only CSV files will be exported if both csv file and google spreadsheet are provided
88
- - In case of multiple CSVs or sheet ids, you should be aware that all sources will be merged. By default the merge policy to keep the first wording translation for each key
89
- - New architecture. Separate export process responsibilities in dedicated classes. Fixes [#48](https://github.com/applidium/ad_localize/issues/48), [#20](https://github.com/applidium/ad_localize/issues/20)
106
+ - In case of multiple CSVs or sheet ids, you should be aware that all sources will be merged. By default the merge
107
+ policy to keep the first wording translation for each key
108
+ - New architecture. Separate export process responsibilities in dedicated classes.
109
+ Fixes [#48](https://github.com/applidium/ad_localize/issues/48)
110
+ , [#20](https://github.com/applidium/ad_localize/issues/20)
90
111
 
91
112
  ### Changed
92
113
 
@@ -121,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
121
142
 
122
143
  ### Removed
123
144
 
124
- - no more option -a option to indicate that a service account configuration will be provided. If set, the environment variable `GCLOUD_CLIENT_SECRET` content will be used
145
+ - no more option -a option to indicate that a service account configuration will be provided. If set, the environment
146
+ variable `GCLOUD_CLIENT_SECRET` content will be used
125
147
  - no more substitution of empty wording with by "Missing Translation" when using the option -d
126
148
  - no more Makefile, the Rakefile is sufficient. Use `bundle exec rake -T` to display the available commands
127
149
  - no more check for ordered interpolation variables in translations
@@ -141,25 +163,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
141
163
 
142
164
  ### Added
143
165
 
144
- - add support for private spreadsheet using google service acccount by [@sjcqs](https://github.com/sjcqs). Fixes [#31](https://github.com/applidium/ad_localize/issues/31)
166
+ - add support for private spreadsheet using google service acccount by [@sjcqs](https://github.com/sjcqs).
167
+ Fixes [#31](https://github.com/applidium/ad_localize/issues/31)
145
168
  - add makefile for easier testing by [@felginep](https://github.com/felginep)
146
169
 
147
170
  ### Changed
148
171
 
149
- - improve error message to have useful information in case of google spreadsheet use by [@felginep](https://github.com/felginep). Fixes [#27](https://github.com/applidium/ad_localize/issues/27)
150
- - platform folder is no longer generated when there is only one platform selected. The files are directly generated in the output path. By [@felginep](https://github.com/felginep). Fixes [#29](https://github.com/applidium/ad_localize/issues/29)
172
+ - improve error message to have useful information in case of google spreadsheet use
173
+ by [@felginep](https://github.com/felginep). Fixes [#27](https://github.com/applidium/ad_localize/issues/27)
174
+ - platform folder is no longer generated when there is only one platform selected. The files are directly generated in
175
+ the output path. By [@felginep](https://github.com/felginep).
176
+ Fixes [#29](https://github.com/applidium/ad_localize/issues/29)
151
177
  - raise error when google spreadsheet key is invalid by [@felginep](https://github.com/felginep)
152
178
 
153
179
  ### Fixed
154
180
 
155
- - auto escape strings in Localizable.strings by [@felginep](https://github.com/felginep). Fixes [#26](https://github.com/applidium/ad_localize/issues/26)
156
- - trim keys to prevent user error by [@felginep](https://github.com/felginep). Fixes [#16](https://github.com/applidium/ad_localize/issues/16)
181
+ - auto escape strings in Localizable.strings by [@felginep](https://github.com/felginep).
182
+ Fixes [#26](https://github.com/applidium/ad_localize/issues/26)
183
+ - trim keys to prevent user error by [@felginep](https://github.com/felginep).
184
+ Fixes [#16](https://github.com/applidium/ad_localize/issues/16)
157
185
 
158
186
  ## [3.4.0] - 2019-02-10
159
187
 
160
188
  ### Added
161
189
 
162
- - Rails folks, [@epaillous](https://github.com/epaillous) has improved the YAML support. You can now have multi-level wording.
190
+ - Rails folks, [@epaillous](https://github.com/epaillous) has improved the YAML support. You can now have multi-level
191
+ wording.
163
192
 
164
193
  ## [3.3.0] - 2019-02-10
165
194
 
@@ -172,7 +201,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
172
201
  ### Added
173
202
 
174
203
  - Add tests to compare reference exports by [@felginep](https://github.com/felginep)
175
- - [iOS only] Handle [adaptive strings](https://developer.apple.com/documentation/foundation/nsstring/1413104-variantfittingpresentationwidth) by [@felginep](https://github.com/felginep)
204
+ - [iOS only]
205
+ Handle [adaptive strings](https://developer.apple.com/documentation/foundation/nsstring/1413104-variantfittingpresentationwidth)
206
+ by [@felginep](https://github.com/felginep)
176
207
 
177
208
  ### Changed
178
209
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ad_localize (4.1.0)
5
- activesupport (>= 6.1.3.2, < 7.0)
4
+ ad_localize (5.0.0)
5
+ activesupport (>= 6.1.3.2, < 8.0)
6
6
  colorize (~> 0.8)
7
7
  google-apis-sheets_v4 (~> 0.9)
8
8
  googleauth (~> 0.12)
@@ -11,21 +11,19 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (6.1.5)
14
+ activesupport (7.0.3.1)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
18
18
  tzinfo (~> 2.0)
19
- zeitwerk (~> 2.3)
20
19
  addressable (2.8.0)
21
20
  public_suffix (>= 2.0.2, < 5.0)
22
21
  ansi (1.5.0)
23
22
  builder (3.2.4)
24
- byebug (11.1.3)
25
23
  colorize (0.8.1)
26
- concurrent-ruby (1.1.9)
24
+ concurrent-ruby (1.1.10)
27
25
  declarative (0.0.20)
28
- diffy (3.3.0)
26
+ diffy (3.4.2)
29
27
  faraday (1.10.0)
30
28
  faraday-em_http (~> 1.0)
31
29
  faraday-em_synchrony (~> 1.0)
@@ -42,14 +40,14 @@ GEM
42
40
  faraday-em_synchrony (1.0.0)
43
41
  faraday-excon (1.1.0)
44
42
  faraday-httpclient (1.0.1)
45
- faraday-multipart (1.0.3)
46
- multipart-post (>= 1.2, < 3)
43
+ faraday-multipart (1.0.4)
44
+ multipart-post (~> 2)
47
45
  faraday-net_http (1.0.1)
48
46
  faraday-net_http_persistent (1.2.0)
49
47
  faraday-patron (1.0.0)
50
48
  faraday-rack (1.0.0)
51
49
  faraday-retry (1.0.3)
52
- google-apis-core (0.4.2)
50
+ google-apis-core (0.7.0)
53
51
  addressable (~> 2.5, >= 2.5.1)
54
52
  googleauth (>= 0.16.2, < 2.a)
55
53
  httpclient (>= 2.8.1, < 3.a)
@@ -58,8 +56,8 @@ GEM
58
56
  retriable (>= 2.0, < 4.a)
59
57
  rexml
60
58
  webrick
61
- google-apis-sheets_v4 (0.11.0)
62
- google-apis-core (>= 0.4, < 2.a)
59
+ google-apis-sheets_v4 (0.17.0)
60
+ google-apis-core (>= 0.7, < 2.a)
63
61
  googleauth (0.17.1)
64
62
  faraday (>= 0.17.3, < 2.0)
65
63
  jwt (>= 1.4, < 3.0)
@@ -68,9 +66,9 @@ GEM
68
66
  os (>= 0.9, < 2.0)
69
67
  signet (~> 0.15)
70
68
  httpclient (2.8.3)
71
- i18n (1.10.0)
69
+ i18n (1.12.0)
72
70
  concurrent-ruby (~> 1.0)
73
- jwt (2.3.0)
71
+ jwt (2.4.1)
74
72
  memoist (0.16.2)
75
73
  mini_mime (1.1.2)
76
74
  mini_portile2 (2.8.0)
@@ -81,15 +79,15 @@ GEM
81
79
  minitest (>= 5.0)
82
80
  ruby-progressbar
83
81
  multi_json (1.15.0)
84
- multipart-post (2.1.1)
85
- nokogiri (1.13.3)
82
+ multipart-post (2.2.3)
83
+ nokogiri (1.13.8)
86
84
  mini_portile2 (~> 2.8.0)
87
85
  racc (~> 1.4)
88
86
  os (1.1.4)
89
- public_suffix (4.0.6)
87
+ public_suffix (4.0.7)
90
88
  racc (1.6.0)
91
89
  rake (12.3.3)
92
- representable (3.1.1)
90
+ representable (3.2.0)
93
91
  declarative (< 0.1.0)
94
92
  trailblazer-option (>= 0.1.1, < 0.2.0)
95
93
  uber (< 0.2.0)
@@ -97,17 +95,16 @@ GEM
97
95
  rexml (3.2.5)
98
96
  ruby-progressbar (1.10.1)
99
97
  ruby2_keywords (0.0.5)
100
- signet (0.16.1)
98
+ signet (0.17.0)
101
99
  addressable (~> 2.8)
102
- faraday (>= 0.17.5, < 3.0)
100
+ faraday (>= 0.17.5, < 3.a)
103
101
  jwt (>= 1.5, < 3.0)
104
102
  multi_json (~> 1.10)
105
103
  trailblazer-option (0.1.2)
106
- tzinfo (2.0.4)
104
+ tzinfo (2.0.5)
107
105
  concurrent-ruby (~> 1.0)
108
106
  uber (0.1.0)
109
107
  webrick (1.7.0)
110
- zeitwerk (2.5.4)
111
108
 
112
109
  PLATFORMS
113
110
  ruby
@@ -115,11 +112,10 @@ PLATFORMS
115
112
  DEPENDENCIES
116
113
  ad_localize!
117
114
  bundler (>= 1.12.0, < 3.0.0)
118
- byebug (~> 11.0)
119
115
  diffy (~> 3.3)
120
116
  minitest (~> 5.11)
121
117
  minitest-reporters (~> 1.3)
122
- rake (~> 12.3)
118
+ rake (>= 12.3.0, < 14.0.0)
123
119
 
124
120
  BUNDLED WITH
125
121
  2.2.26
data/README.md CHANGED
@@ -66,6 +66,11 @@ $ ad_localize -t <path-to-the-output-directory>
66
66
  $ ad_localize -d
67
67
  ```
68
68
 
69
+ * Won't generate keys with empty values (iOS feature only, automatically handled for Android)
70
+ ```
71
+ $ ad_localize -x
72
+ ```
73
+
69
74
  ### In a Ruby program
70
75
  There are many possibilities when using AdLocalize in a ruby program. You can add support to your own wording format, support other platforms, select which locales you want to export, generate wording file content without writing on the disk and many more.
71
76
 
data/ad_localize.gemspec CHANGED
@@ -21,9 +21,10 @@ Gem::Specification.new do |spec|
21
21
  'Claire Peyron',
22
22
  'Claire Dufetrelle',
23
23
  'Pierre Felgines',
24
- 'Satyan Jacquens'
24
+ 'Satyan Jacquens',
25
+ 'Thomas Esterlin'
25
26
  ]
26
- spec.email = %w(joanna.vigne@fabernovel.com hugo.hache@fabernovel.com edouard.siegel@fabernovel.com)
27
+ spec.email = %w(joanna.vigne@fabernovel.com pierre.felgines@fabernovel.com edouard.siegel@fabernovel.com)
27
28
 
28
29
  spec.summary = %q{AdLocalize helps with mobile and web applications wording}
29
30
  spec.description = %q{AdLocalize produces localization files from platform agnostic wording.
@@ -40,17 +41,16 @@ Gem::Specification.new do |spec|
40
41
  spec.require_paths = ['lib']
41
42
 
42
43
  spec.add_development_dependency 'bundler', '>= 1.12.0', '< 3.0.0'
43
- spec.add_development_dependency 'rake', '~> 12.3'
44
+ spec.add_development_dependency 'rake', '>= 12.3.0', '< 14.0.0'
44
45
  spec.add_development_dependency 'minitest', '~> 5.11'
45
- spec.add_development_dependency 'byebug', '~> 11.0'
46
46
  spec.add_development_dependency 'minitest-reporters', '~> 1.3'
47
47
  spec.add_development_dependency 'diffy', '~> 3.3'
48
48
 
49
- spec.add_dependency 'activesupport', '>= 6.1.3.2', '< 7.0'
49
+ spec.add_dependency 'activesupport', '>= 6.1.3.2', '< 8.0'
50
50
  spec.add_dependency 'nokogiri', '~> 1.10'
51
51
  spec.add_dependency 'colorize', '~> 0.8'
52
52
  spec.add_dependency 'googleauth', '~> 0.12'
53
53
  spec.add_dependency 'google-apis-sheets_v4', '~> 0.9'
54
54
 
55
- spec.required_ruby_version = '>= 2.3'
55
+ spec.required_ruby_version = '>= 2.7'
56
56
  end
data/bin/console CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "ad_localize"
5
- require 'byebug'
6
5
 
7
6
  # You can add fixtures and/or initialization code here to make experimenting
8
7
  # with your gem easier. You can also use a different console, if you like.
@@ -11,6 +11,7 @@ module AdLocalize
11
11
  print_export_request(export_request: export_request) if export_request.verbose?
12
12
  LOGGER.debug("Checking request validity")
13
13
  return unless export_request.valid?
14
+
14
15
  if export_request.has_csv_files?
15
16
  ExportCSVFiles.new(csv_path_to_wording: @csv_path_to_wording).call(export_request: export_request)
16
17
  elsif export_request.has_g_spreadsheet_options?
@@ -27,6 +28,7 @@ module AdLocalize
27
28
  LOGGER.debug("platforms : #{export_request.platforms.to_sentence}")
28
29
  LOGGER.debug("output_path : #{export_request.output_path}")
29
30
  LOGGER.debug("verbose : #{export_request.verbose}")
31
+ LOGGER.debug("non_empty_values : #{export_request.non_empty_values}")
30
32
  LOGGER.debug("merge_policy : #{export_request.merge_policy&.policy}")
31
33
  LOGGER.debug("csv_paths : #{export_request.csv_paths.to_sentence}")
32
34
  if export_request.has_g_spreadsheet_options?
@@ -4,13 +4,16 @@ module AdLocalize
4
4
  def initialize(csv_path_to_wording: nil)
5
5
  @csv_path_to_wording = csv_path_to_wording.presence || Mappers::CSVPathToWording.new
6
6
  @merge_wordings = MergeWordings.new
7
+ @export_wording = ExportWording.new
7
8
  end
8
9
 
9
10
  def call(export_request:)
10
11
  LOGGER.debug("Starting export csv files : #{export_request.csv_paths.to_sentence}")
11
- wordings = export_request.csv_paths.map { |csv_path| @csv_path_to_wording.map(csv_path: csv_path) }
12
- wording = @merge_wordings.call(wordings: wordings.compact, merge_policy: export_request.merge_policy)
13
- ExportWording.new.call(export_request: export_request, wording: wording)
12
+ wordings = export_request.csv_paths.map { |csv_path| @csv_path_to_wording.map(csv_path: csv_path) }.compact
13
+ return if wordings.blank?
14
+
15
+ wording = @merge_wordings.call(wordings: wordings, merge_policy: export_request.merge_policy)
16
+ @export_wording.call(export_request: export_request, wording: wording)
14
17
  end
15
18
  end
16
19
  end
@@ -4,6 +4,9 @@ module AdLocalize
4
4
  def initialize(value_range_to_wording: nil)
5
5
  @value_range_to_wording = value_range_to_wording.presence || Mappers::ValueRangeToWording.new
6
6
  @g_sheets_repository = Repositories::GSheetsRepository.new
7
+ @export_wording = ExportWording.new
8
+ @merge_wordings = MergeWordings.new
9
+ @export_csv_files = ExportCSVFiles.new
7
10
  end
8
11
 
9
12
  def call(export_request:)
@@ -20,9 +23,11 @@ module AdLocalize
20
23
  def export_with_service_account(export_request:)
21
24
  LOGGER.debug("Using service account")
22
25
  value_ranges = @g_sheets_repository.get_sheets_values(g_spreadsheet_options: export_request.g_spreadsheet_options)
23
- wordings = value_ranges.map { |value_range| @value_range_to_wording.map(value_range: value_range) }
24
- wording = MergeWordings.new.call(wordings: wordings.compact, merge_policy: export_request.merge_policy)
25
- ExportWording.new.call(export_request: export_request, wording: wording)
26
+ wordings = value_ranges.map { |value_range| @value_range_to_wording.map(value_range: value_range) }.compact
27
+ return if wordings.blank?
28
+
29
+ wording = @merge_wordings.call(wordings: wordings, merge_policy: export_request.merge_policy)
30
+ @export_wording.call(export_request: export_request, wording: wording)
26
31
  end
27
32
 
28
33
  def export_without_service_account(export_request:)
@@ -32,7 +37,7 @@ module AdLocalize
32
37
  end
33
38
  export_request.csv_paths = downloaded_files.map(&:path)
34
39
  if export_request.has_csv_files?
35
- ExportCSVFiles.new.call(export_request: export_request)
40
+ @export_csv_files.call(export_request: export_request)
36
41
  elsif export_request.has_empty_files?
37
42
  # When downloading an empty spreadsheet, the content type of the downloaded file is "inode/x-empty"
38
43
  LOGGER.warn("Your spreadsheet is empty. Add content and retry.")
@@ -8,23 +8,26 @@ module AdLocalize
8
8
  def call(export_request:, wording:)
9
9
  LOGGER.debug("Starting export wording")
10
10
  export_request.platforms.each do |platform|
11
- platform_dir = compute_platform_dir(export_request: export_request, platform: platform)
12
- export_platform = @export_platform_factory.build(platform: platform)
13
- if export_platform.should_export_locale_by_locale?
14
- locales = export_request.locales.size.zero? ? wording.locales : wording.locales & export_request.locales
15
- locales.each do |locale|
16
- export_platform.call(wording: wording, locale: locale, platform_dir: platform_dir)
17
- end
18
- else
19
- export_platform.call(export_request: export_request, platform_dir: platform_dir)
20
- end
11
+ platform_interactor = @export_platform_factory.build(platform: platform)
12
+ options = build_export_wording_options(wording: wording, export_request: export_request, platform: platform)
13
+ platform_interactor.call(export_wording_options: options)
21
14
  end
22
15
  end
23
16
 
24
17
  private
25
18
 
26
- def compute_platform_dir(export_request:, platform:)
27
- export_request.multiple_platforms? ? export_request.output_path.join(platform.to_s) : export_request.output_path
19
+ def build_export_wording_options(wording:, export_request:, platform:)
20
+ platform_output_directory = export_request.output_path
21
+ platform_output_directory = platform_output_directory.join(platform.to_s) if export_request.multiple_platforms?
22
+ locales = export_request.locales.size.zero? ? wording.locales : wording.locales & export_request.locales
23
+
24
+ Requests::ExportWordingOptions.new(
25
+ locales: locales,
26
+ wording: wording,
27
+ platform_output_directory: platform_output_directory,
28
+ bypass_empty_values: export_request.non_empty_values,
29
+ csv_paths: export_request.csv_paths
30
+ )
28
31
  end
29
32
  end
30
33
  end
@@ -10,21 +10,22 @@ module AdLocalize
10
10
  @file_system_repository = Repositories::FileSystemRepository.new
11
11
  end
12
12
 
13
- def call(wording:, locale:, platform_dir:)
14
- LOGGER.debug("Starting export Android wording for locale #{locale}")
15
- locale_wording = wording.translations_for(locale: locale)
16
- return unless has_android_wording?(locale_wording: locale_wording)
17
-
18
- output_dir = compute_output_dir(wording: wording, locale: locale, platform_dir: platform_dir)
19
- @file_system_repository.create_directory(path: output_dir)
20
-
21
- content = @strings_serializer.render(locale_wording: locale_wording)
22
- @file_system_repository.write(content: content, path: output_dir.join(STRINGS_FILENAME))
23
- LOGGER.debug("#{STRINGS_FILENAME} done !")
24
- end
25
-
26
- def should_export_locale_by_locale?
27
- true
13
+ def call(export_wording_options:)
14
+ platform_dir = export_wording_options.platform_output_directory
15
+ wording = export_wording_options.wording
16
+
17
+ export_wording_options.locales.each do |locale|
18
+ LOGGER.debug("Starting export Android wording for locale #{locale}")
19
+ locale_wording = export_wording_options.wording.translations_for(locale: locale)
20
+ return unless has_android_wording?(locale_wording: locale_wording)
21
+
22
+ output_dir = compute_output_dir(wording: wording, locale: locale, platform_dir: platform_dir)
23
+ @file_system_repository.create_directory(path: output_dir)
24
+
25
+ content = @strings_serializer.render(locale_wording: locale_wording)
26
+ @file_system_repository.write(content: content, path: output_dir.join(STRINGS_FILENAME))
27
+ LOGGER.debug("#{STRINGS_FILENAME} done !")
28
+ end
28
29
  end
29
30
 
30
31
  private
@@ -6,19 +6,16 @@ module AdLocalize
6
6
  @file_system_repository = Repositories::FileSystemRepository.new
7
7
  end
8
8
 
9
- def call(export_request:, platform_dir:)
9
+ def call(export_wording_options:)
10
10
  LOGGER.debug("Starting export CSV wording")
11
- @file_system_repository.create_directory(path: platform_dir)
12
- export_request.csv_paths.each_with_index do |csv_path, i|
11
+ @file_system_repository.create_directory(path: export_wording_options.platform_output_directory)
12
+ export_wording_options.csv_paths.each_with_index do |csv_path, i|
13
13
  file = File.basename("localization_#{i}.csv")
14
- FileUtils.cp(csv_path, platform_dir.join(file.to_s))
14
+ output_path = export_wording_options.platform_output_directory.join(file.to_s)
15
+ FileUtils.cp(csv_path, output_path)
15
16
  end
16
17
  LOGGER.debug("CSV wording export done !")
17
18
  end
18
-
19
- def should_export_locale_by_locale?
20
- false
21
- end
22
19
  end
23
20
  end
24
21
  end
@@ -9,30 +9,34 @@ module AdLocalize
9
9
 
10
10
  def initialize
11
11
  @info_plist_serializer = Serializers::InfoPlistSerializer.new
12
- @localizable_strings_serializer = Serializers::LocalizableStringsSerializer.new
13
- @localizable_stringsdict_serializer = Serializers::LocalizableStringsdictSerializer.new
12
+ @strings_serializer = Serializers::LocalizableStringsSerializer.new
13
+ @stringsdict_serializer = Serializers::LocalizableStringsdictSerializer.new
14
14
  @file_system_repository = Repositories::FileSystemRepository.new
15
15
  end
16
16
 
17
- def call(wording:, locale:, platform_dir:)
18
- LOGGER.debug("Starting export iOS wording for locale #{locale}")
19
- locale_wording = wording.translations_for(locale: locale)
20
- return unless has_ios_wording?(locale_wording: locale_wording)
17
+ def call(export_wording_options:)
18
+ bypass_empty_values = export_wording_options.bypass_empty_values
21
19
 
22
- output_dir = platform_dir.join(LOCALE_DIRECTORY_CONVENTION % { locale: locale })
23
- @file_system_repository.create_directory(path: output_dir)
20
+ export_wording_options.locales.each do |locale|
21
+ LOGGER.debug("Starting export iOS wording for locale #{locale}")
22
+ locale_wording = export_wording_options.wording.translations_for(locale: locale)
23
+ next unless has_ios_wording?(locale_wording: locale_wording)
24
24
 
25
- export_info_plist(locale_wording: locale_wording, output_dir: output_dir)
26
- export_localizable_strings(locale_wording: locale_wording, output_dir: output_dir)
27
- export_localizable_stringsdict(locale_wording: locale_wording, output_dir: output_dir)
28
- end
29
-
30
- def should_export_locale_by_locale?
31
- true
25
+ locale_directory_name = LOCALE_DIRECTORY_CONVENTION % { locale: locale }
26
+ output_dir = export_wording_options.platform_output_directory.join(locale_directory_name)
27
+ @file_system_repository.create_directory(path: output_dir)
28
+ export_files(locale_wording: locale_wording, output_dir: output_dir, bypass_empty_values: bypass_empty_values)
29
+ end
32
30
  end
33
31
 
34
32
  private
35
33
 
34
+ def export_files(locale_wording:, output_dir:, bypass_empty_values:)
35
+ export_info_plist(locale_wording: locale_wording, output_dir: output_dir)
36
+ export_localizable_strings(locale_wording: locale_wording, output_dir: output_dir, bypass_empty_values: bypass_empty_values)
37
+ export_localizable_stringsdict(locale_wording: locale_wording, output_dir: output_dir, bypass_empty_values: bypass_empty_values)
38
+ end
39
+
36
40
  def has_ios_wording?(locale_wording:)
37
41
  locale_wording.has_info_plist_keys? ||
38
42
  locale_wording.has_singular_keys? ||
@@ -42,21 +46,26 @@ module AdLocalize
42
46
 
43
47
  def export_info_plist(locale_wording:, output_dir:)
44
48
  return unless locale_wording.has_info_plist_keys?
49
+
45
50
  content = @info_plist_serializer.render(locale_wording: locale_wording)
46
51
  @file_system_repository.write(content: content, path: output_dir.join(INFO_PLIST_FILENAME))
47
52
  LOGGER.debug("#{INFO_PLIST_FILENAME} done !")
48
53
  end
49
54
 
50
- def export_localizable_strings(locale_wording:, output_dir:)
55
+ def export_localizable_strings(locale_wording:, output_dir:, bypass_empty_values:)
51
56
  return unless locale_wording.has_singular_keys?
52
- content = @localizable_strings_serializer.render(locale_wording: locale_wording)
57
+
58
+ @strings_serializer.bypass_empty_values = bypass_empty_values
59
+ content = @strings_serializer.render(locale_wording: locale_wording)
53
60
  @file_system_repository.write(content: content, path: output_dir.join(LOCALIZABLE_STRINGS_FILENAME))
54
61
  LOGGER.debug("#{LOCALIZABLE_STRINGS_FILENAME} done !")
55
62
  end
56
63
 
57
- def export_localizable_stringsdict(locale_wording:, output_dir:)
64
+ def export_localizable_stringsdict(locale_wording:, output_dir:, bypass_empty_values:)
58
65
  return unless locale_wording.has_plural_keys? || locale_wording.has_adaptive_keys?
59
- content = @localizable_stringsdict_serializer.render(locale_wording: locale_wording)
66
+
67
+ @stringsdict_serializer.bypass_empty_values = bypass_empty_values
68
+ content = @stringsdict_serializer.render(locale_wording: locale_wording)
60
69
  @file_system_repository.write(content: content, path: output_dir.join(LOCALIZABLE_STRINGSDICT_FILENAME))
61
70
  LOGGER.debug("#{LOCALIZABLE_STRINGSDICT_FILENAME} done !")
62
71
  end
@@ -7,19 +7,19 @@ module AdLocalize
7
7
  @file_system_repository = Repositories::FileSystemRepository.new
8
8
  end
9
9
 
10
- def call(wording:, locale:, platform_dir:)
11
- LOGGER.debug("Starting export JSON wording for locale #{locale}")
12
- locale_wording = wording.translations_for(locale: locale)
13
- content = @json_serializer.render(locale_wording: locale_wording)
14
- return if content[locale].blank?
10
+ def call(export_wording_options:)
11
+ output_dir = export_wording_options.platform_output_directory
15
12
 
16
- @file_system_repository.create_directory(path: platform_dir)
17
- @file_system_repository.write(content: content, path: platform_dir.join("#{locale}.json"))
18
- LOGGER.debug("#{locale}.json done !")
19
- end
13
+ export_wording_options.locales.each do |locale|
14
+ LOGGER.debug("Starting export JSON wording for locale #{locale}")
15
+ locale_wording = export_wording_options.wording.translations_for(locale: locale)
16
+ content = @json_serializer.render(locale_wording: locale_wording)
17
+ next if content[locale].blank?
20
18
 
21
- def should_export_locale_by_locale?
22
- true
19
+ @file_system_repository.create_directory(path: output_dir)
20
+ @file_system_repository.write(content: content, path: output_dir.join("#{locale}.json"))
21
+ LOGGER.debug("#{locale}.json done !")
22
+ end
23
23
  end
24
24
  end
25
25
  end
@@ -7,19 +7,18 @@ module AdLocalize
7
7
  @file_system_repository = Repositories::FileSystemRepository.new
8
8
  end
9
9
 
10
- def call(wording:, locale:, platform_dir:)
11
- LOGGER.debug("Starting export Properties wording for locale #{locale}")
12
- locale_wording = wording.translations_for(locale: locale)
13
- return unless has_properties_wording?(locale_wording: locale_wording)
10
+ def call(export_wording_options:)
11
+ export_wording_options.locales.each do |locale|
12
+ LOGGER.debug("Starting export Properties wording for locale #{locale}")
13
+ locale_wording = export_wording_options.wording.translations_for(locale: locale)
14
+ return unless has_properties_wording?(locale_wording: locale_wording)
14
15
 
15
- content = @properties_serializer.render(locale_wording: locale_wording)
16
- @file_system_repository.create_directory(path: platform_dir)
17
- @file_system_repository.write(content: content, path: platform_dir.join("#{locale}.properties"))
18
- LOGGER.debug("#{locale}.properties done !")
19
- end
20
-
21
- def should_export_locale_by_locale?
22
- true
16
+ content = @properties_serializer.render(locale_wording: locale_wording)
17
+ @file_system_repository.create_directory(path: export_wording_options.platform_output_directory)
18
+ output_path = export_wording_options.platform_output_directory.join("#{locale}.properties")
19
+ @file_system_repository.write(content: content, path: output_path)
20
+ LOGGER.debug("#{locale}.properties done !")
21
+ end
23
22
  end
24
23
 
25
24
  private
@@ -7,19 +7,19 @@ module AdLocalize
7
7
  @file_system_repository = Repositories::FileSystemRepository.new
8
8
  end
9
9
 
10
- def call(wording:, locale:, platform_dir:)
11
- LOGGER.debug("Starting export YAML wording for locale #{locale}")
12
- locale_wording = wording.translations_for(locale: locale)
13
- content = @yaml_serializer.render(locale_wording:locale_wording)
14
- return if content[locale].blank?
10
+ def call(export_wording_options:)
11
+ output_dir = export_wording_options.platform_output_directory
15
12
 
16
- @file_system_repository.create_directory(path: platform_dir)
17
- @file_system_repository.write(content: content, path: platform_dir.join("#{locale}.yml"))
18
- LOGGER.debug("#{locale}.yml done !")
19
- end
13
+ export_wording_options.locales.each do |locale|
14
+ LOGGER.debug("Starting export YAML wording for locale #{locale}")
15
+ locale_wording = export_wording_options.wording.translations_for(locale: locale)
16
+ content = @yaml_serializer.render(locale_wording: locale_wording)
17
+ next if content[locale].blank?
20
18
 
21
- def should_export_locale_by_locale?
22
- true
19
+ @file_system_repository.create_directory(path: output_dir)
20
+ @file_system_repository.write(content: content, path: output_dir.join("#{locale}.yml"))
21
+ LOGGER.debug("#{locale}.yml done !")
22
+ end
23
23
  end
24
24
  end
25
25
  end
@@ -6,6 +6,7 @@ module AdLocalize
6
6
  platforms: options[:only],
7
7
  g_spreadsheet_options: map_g_spreadsheet_options(options: options),
8
8
  verbose: options[:debug],
9
+ non_empty_values: options[:'non-empty-values'],
9
10
  output_path: options[:'target-dir'],
10
11
  merge_policy: options[:'merge-policy'],
11
12
  csv_paths: options[:csv_paths]
@@ -27,6 +27,7 @@ module AdLocalize
27
27
  parser.on("-o", "--only PLATFORMS", Array, "PLATFORMS is a comma separated list. Only generate localisation files for the specified platforms. Supported platforms : #{Requests::ExportRequest::SUPPORTED_PLATFORMS.to_sentence}")
28
28
  parser.on("-s", "--sheets SHEET_IDS", Array, "SHEET_IDS is a comma separated list. Use a specific sheet id for Google Drive spreadsheets with several sheets")
29
29
  parser.on("-t", "--target-dir PATH", String, "Path to the target directory")
30
+ parser.on("-x", "--non-empty-values", TrueClass, "Do not export keys with empty values (iOS only)")
30
31
  end
31
32
 
32
33
  args = {}
@@ -12,6 +12,7 @@ module AdLocalize
12
12
  @csv_paths = Array(args[:csv_paths])
13
13
  @g_spreadsheet_options = args[:g_spreadsheet_options]
14
14
  @verbose = args[:verbose].presence || false
15
+ @non_empty_values = args[:non_empty_values].presence || false
15
16
  @output_path = Pathname.new(args[:output_path].presence || DEFAULT_EXPORT_FOLDER)
16
17
  if @csv_paths.size > 1 || @g_spreadsheet_options&.has_multiple_sheets?
17
18
  @merge_policy = MergePolicy.new(policy: args[:merge_policy].presence || MergePolicy::DEFAULT_POLICY)
@@ -26,6 +27,7 @@ module AdLocalize
26
27
  :g_spreadsheet_options,
27
28
  :output_path,
28
29
  :verbose,
30
+ :non_empty_values,
29
31
  :merge_policy
30
32
  )
31
33
 
@@ -55,6 +57,10 @@ module AdLocalize
55
57
  verbose
56
58
  end
57
59
 
60
+ def non_empty_values?
61
+ non_empty_values
62
+ end
63
+
58
64
  private
59
65
 
60
66
  def valid_csv_options?
@@ -0,0 +1,24 @@
1
+ module AdLocalize
2
+ module Requests
3
+ class ExportWordingOptions
4
+ def initialize(wording:, platform_output_directory:, locales: [], bypass_empty_values: false, csv_paths: [])
5
+ @wording = wording
6
+ @locales = locales
7
+ @platform_output_directory = platform_output_directory
8
+ @bypass_empty_values = bypass_empty_values
9
+ @csv_paths = csv_paths
10
+ end
11
+
12
+ attr_reader(
13
+ :wording,
14
+ :platform_output_directory,
15
+ :bypass_empty_values,
16
+ :locales
17
+ )
18
+
19
+ attr_accessor(
20
+ :csv_paths
21
+ )
22
+ end
23
+ end
24
+ end
@@ -9,6 +9,10 @@ module AdLocalize
9
9
  @translation_mapper = Mappers::IOSTranslationMapper.new
10
10
  end
11
11
 
12
+ attr_accessor(
13
+ :bypass_empty_values
14
+ )
15
+
12
16
  private
13
17
 
14
18
  def template_path
@@ -20,7 +24,7 @@ module AdLocalize
20
24
  end
21
25
 
22
26
  def map_translations(translations:)
23
- translations.map { |translation| @translation_mapper.map(translation: translation) }
27
+ translations.select(&:has_value?).map { |translation| @translation_mapper.map(translation: translation) }
24
28
  end
25
29
  end
26
30
  end
@@ -10,6 +10,10 @@ module AdLocalize
10
10
  @translation_group_mapper = Mappers::TranslationGroupMapper.new(translation_mapper: @translation_mapper)
11
11
  end
12
12
 
13
+ attr_accessor(
14
+ :bypass_empty_values
15
+ )
16
+
13
17
  private
14
18
 
15
19
  def template_path
@@ -24,11 +28,13 @@ module AdLocalize
24
28
  end
25
29
 
26
30
  def map_plurals(plurals:)
27
- plurals.map { |label, translations| @translation_group_mapper.map(label: label, translations: translations) }
31
+ plurals.map { |label, translations| @translation_group_mapper.map(label: label, translations: translations.select(&:has_value?)) }
32
+ .select(&:has_translations?)
28
33
  end
29
34
 
30
35
  def map_adaptives(adaptives:)
31
- adaptives.map { |label, translations| @translation_group_mapper.map(label: label, translations: translations) }
36
+ adaptives.map { |label, translations| @translation_group_mapper.map(label: label, translations: translations.select(&:has_value?)) }
37
+ .select(&:has_translations?)
32
38
  end
33
39
  end
34
40
  end
@@ -1,3 +1,3 @@
1
1
  module AdLocalize
2
- VERSION = "4.1.1"
2
+ VERSION = "5.0.0"
3
3
  end
data/lib/ad_localize.rb CHANGED
@@ -41,6 +41,7 @@ require 'ad_localize/entities/wording'
41
41
 
42
42
  require 'ad_localize/requests/g_spreadsheet_options'
43
43
  require 'ad_localize/requests/export_request'
44
+ require 'ad_localize/requests/export_wording_options'
44
45
  require 'ad_localize/requests/merge_policy'
45
46
 
46
47
  require 'ad_localize/interactors/merge_wordings'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad_localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Siegel
@@ -17,7 +17,8 @@ authors:
17
17
  - Claire Dufetrelle
18
18
  - Pierre Felgines
19
19
  - Satyan Jacquens
20
- autorequire:
20
+ - Thomas Esterlin
21
+ autorequire:
21
22
  bindir: exe
22
23
  cert_chain: []
23
24
  date: 2018-04-18 00:00:00.000000000 Z
@@ -46,16 +47,22 @@ dependencies:
46
47
  name: rake
47
48
  requirement: !ruby/object:Gem::Requirement
48
49
  requirements:
49
- - - "~>"
50
+ - - ">="
50
51
  - !ruby/object:Gem::Version
51
- version: '12.3'
52
+ version: 12.3.0
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: 14.0.0
52
56
  type: :development
53
57
  prerelease: false
54
58
  version_requirements: !ruby/object:Gem::Requirement
55
59
  requirements:
56
- - - "~>"
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 12.3.0
63
+ - - "<"
57
64
  - !ruby/object:Gem::Version
58
- version: '12.3'
65
+ version: 14.0.0
59
66
  - !ruby/object:Gem::Dependency
60
67
  name: minitest
61
68
  requirement: !ruby/object:Gem::Requirement
@@ -70,20 +77,6 @@ dependencies:
70
77
  - - "~>"
71
78
  - !ruby/object:Gem::Version
72
79
  version: '5.11'
73
- - !ruby/object:Gem::Dependency
74
- name: byebug
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '11.0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: '11.0'
87
80
  - !ruby/object:Gem::Dependency
88
81
  name: minitest-reporters
89
82
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +114,7 @@ dependencies:
121
114
  version: 6.1.3.2
122
115
  - - "<"
123
116
  - !ruby/object:Gem::Version
124
- version: '7.0'
117
+ version: '8.0'
125
118
  type: :runtime
126
119
  prerelease: false
127
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -131,7 +124,7 @@ dependencies:
131
124
  version: 6.1.3.2
132
125
  - - "<"
133
126
  - !ruby/object:Gem::Version
134
- version: '7.0'
127
+ version: '8.0'
135
128
  - !ruby/object:Gem::Dependency
136
129
  name: nokogiri
137
130
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +186,7 @@ description: |-
193
186
  Supported wording format : CSV. Supported export format: iOS, Android, JSON and YAML
194
187
  email:
195
188
  - joanna.vigne@fabernovel.com
196
- - hugo.hache@fabernovel.com
189
+ - pierre.felgines@fabernovel.com
197
190
  - edouard.siegel@fabernovel.com
198
191
  executables:
199
192
  - ad_localize
@@ -247,6 +240,7 @@ files:
247
240
  - lib/ad_localize/repositories/file_system_repository.rb
248
241
  - lib/ad_localize/repositories/g_sheets_repository.rb
249
242
  - lib/ad_localize/requests/export_request.rb
243
+ - lib/ad_localize/requests/export_wording_options.rb
250
244
  - lib/ad_localize/requests/g_spreadsheet_options.rb
251
245
  - lib/ad_localize/requests/merge_policy.rb
252
246
  - lib/ad_localize/serializers/info_plist_serializer.rb
@@ -270,7 +264,7 @@ homepage: https://github.com/applidium/ad_localize
270
264
  licenses:
271
265
  - MIT
272
266
  metadata: {}
273
- post_install_message:
267
+ post_install_message:
274
268
  rdoc_options: []
275
269
  require_paths:
276
270
  - lib
@@ -278,15 +272,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
272
  requirements:
279
273
  - - ">="
280
274
  - !ruby/object:Gem::Version
281
- version: '2.3'
275
+ version: '2.7'
282
276
  required_rubygems_version: !ruby/object:Gem::Requirement
283
277
  requirements:
284
278
  - - ">="
285
279
  - !ruby/object:Gem::Version
286
280
  version: '0'
287
281
  requirements: []
288
- rubygems_version: 3.2.26
289
- signing_key:
282
+ rubygems_version: 3.2.15
283
+ signing_key:
290
284
  specification_version: 4
291
285
  summary: AdLocalize helps with mobile and web applications wording
292
286
  test_files: []