ad_localize 6.0.0 → 6.1.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/ad_localize/interactors/base_generate_files.rb +1 -0
- data/lib/ad_localize/mappers/options_to_export_request.rb +1 -0
- data/lib/ad_localize/option_handler.rb +32 -19
- data/lib/ad_localize/requests/export_request.rb +8 -0
- data/lib/ad_localize/sanitizers/ios_sanitizer.rb +12 -1
- data/lib/ad_localize/serializers/localizable_strings_serializer.rb +4 -0
- data/lib/ad_localize/serializers/localizable_stringsdict_serializer.rb +4 -0
- data/lib/ad_localize/serializers/templated_serializer.rb +4 -0
- data/lib/ad_localize/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b70487e0e8087dbbdb3c6873b025748b9fc97e68ac2abc5c13a0fe71a1a1011c
|
4
|
+
data.tar.gz: c82fe7eeb8bc946411c094f51d69df40a35bc9b9e5c5805203a976c4d2aba9c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8acdef650f29ede65b72fed96666be542f078337dd6e7b950a8be2ec18b1ff55ee65279dcd5736e5b4d229fed9796b30480cee9b72194ad1bdbba87fa388d81b
|
7
|
+
data.tar.gz: cad8b9ba73f3055cb7d000fdda14eb45f59a418d6e563a5d272855ff86000779c221282b07e8f33f07f793ecaec6e9150dc9b889c485e8a1496ee1839a5b9daa
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ 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
8
|
## Unreleased
|
9
|
+
|
10
|
+
## 6.1.0
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- new option (iOS only) `--auto-escape-percent` that escapes % character in wording. This option should be used if the wording is intended to be used with `String(format:)`.
|
14
|
+
|
15
|
+
## 6.0.0
|
9
16
|
### Added
|
10
17
|
|
11
18
|
- Remove extra spaces before and after key/translation contents
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -76,6 +76,11 @@ $ ad_localize -d
|
|
76
76
|
$ ad_localize -x
|
77
77
|
```
|
78
78
|
|
79
|
+
* Will escape % character present in wordings (iOS feature only), this is useful when using the wording through String(format:)
|
80
|
+
```
|
81
|
+
$ ad_localize --auto-escape-percent
|
82
|
+
```
|
83
|
+
|
79
84
|
* Only generate wording files for the specified locales
|
80
85
|
```
|
81
86
|
$ ad_localize -l fr,en
|
@@ -10,6 +10,7 @@ module AdLocalize
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(wording:, export_request:)
|
13
|
+
@serializer.configure(export_request: export_request) if @serializer.respond_to?(:configure)
|
13
14
|
wording.each do |locale, locale_wording|
|
14
15
|
next unless has_wording?(locale_wording: locale_wording)
|
15
16
|
|
@@ -6,6 +6,7 @@ module AdLocalize
|
|
6
6
|
request = Requests::ExportRequest.new
|
7
7
|
request.locales = options[:locales]
|
8
8
|
request.bypass_empty_values = options[:'non-empty-values']
|
9
|
+
request.auto_escape_percent = options[:'auto-escape-percent']
|
9
10
|
request.csv_paths = options[:csv_paths]
|
10
11
|
request.merge_policy = options[:'merge-policy']
|
11
12
|
request.output_path = options[:'target-dir']
|
@@ -4,6 +4,7 @@ module AdLocalize
|
|
4
4
|
DEFAULT_OPTIONS = {
|
5
5
|
locales: Requests::ExportRequest::DEFAULTS[:locales],
|
6
6
|
:'non-empty-values' => Requests::ExportRequest::DEFAULTS[:bypass_empty_values],
|
7
|
+
:'auto-escape-percent' => Requests::ExportRequest::DEFAULTS[:auto_escape_percent],
|
7
8
|
csv_paths: Requests::ExportRequest::DEFAULTS[:csv_paths],
|
8
9
|
:'merge-policy' => Requests::ExportRequest::DEFAULTS[:merge_policy],
|
9
10
|
:'target-dir' => Requests::ExportRequest::DEFAULTS[:output_path],
|
@@ -16,26 +17,10 @@ module AdLocalize
|
|
16
17
|
|
17
18
|
def self.parse!(options)
|
18
19
|
args = DEFAULT_OPTIONS
|
19
|
-
export_all_option = <<~DOC
|
20
|
-
Export all sheets from spreadsheet specified by --drive-key option.
|
21
|
-
\tBy default, generates one export directory per sheet (see -m|--merge-sheets option to merge them).
|
22
|
-
\tAn GCLOUD_CLIENT_SECRET environment variable containing the client_secret.json content is needed.
|
23
|
-
DOC
|
24
|
-
merge_policy_option = <<~DOC
|
25
|
-
Merge specified csv (or sheets from --export-all) instead of exporting each csv.
|
26
|
-
\treplace: if a key is already defined, replace its value.
|
27
|
-
\tkeep: if a key is already defined, keep the previous value.
|
28
|
-
DOC
|
29
|
-
platforms_option = <<~DOC
|
30
|
-
PLATFORMS is a comma separated list.
|
31
|
-
\tOnly generate localisation files for the specified platforms.
|
32
|
-
\tSupported platforms : #{Entities::Platform::SUPPORTED_PLATFORMS.to_sentence}
|
33
|
-
DOC
|
34
|
-
|
35
20
|
OptionParser.new do |parser|
|
36
21
|
parser.banner = 'Usage: exe/ad_localize [options] file(s)'
|
37
22
|
parser.on("-d", "--debug", TrueClass, 'Run in debug mode')
|
38
|
-
parser
|
23
|
+
export_all_option(parser)
|
39
24
|
parser.on("-h", "--help", 'Prints help') do
|
40
25
|
puts parser
|
41
26
|
exit
|
@@ -43,8 +28,8 @@ module AdLocalize
|
|
43
28
|
parser.on("-k", "--drive-key SPREADSHEET_ID", String, 'Use google drive spreadsheets')
|
44
29
|
parser.on("-l", "--locales LOCALES", Array,
|
45
30
|
'LOCALES is a comma separated list. Only generate localisation files for the specified locales')
|
46
|
-
parser
|
47
|
-
parser
|
31
|
+
merge_policy_option(parser)
|
32
|
+
platforms_option(parser)
|
48
33
|
parser.on("-s", "--sheets SHEET_IDS", Array,
|
49
34
|
'SHEET_IDS is a comma separated list. Use a specific sheet id for Google Drive spreadsheets with several sheets')
|
50
35
|
parser.on("-t", "--target-dir PATH", String, 'Path to the target directory')
|
@@ -53,10 +38,38 @@ module AdLocalize
|
|
53
38
|
exit
|
54
39
|
end
|
55
40
|
parser.on("-x", "--non-empty-values", TrueClass, 'Do not export keys with empty values (iOS only)')
|
41
|
+
parser.on("--auto-escape-percent", TrueClass, 'Add escaping for % symbol to support wording use with String formatting (iOS only)')
|
56
42
|
end.parse!(options, into: args)
|
57
43
|
|
58
44
|
args[:csv_paths] = options
|
59
45
|
return args
|
60
46
|
end
|
47
|
+
|
48
|
+
def self.export_all_option(parser)
|
49
|
+
export_all_option = <<~DOC
|
50
|
+
Export all sheets from spreadsheet specified by --drive-key option.
|
51
|
+
\tBy default, generates one export directory per sheet (see -m|--merge-sheets option to merge them).
|
52
|
+
\tAn GCLOUD_CLIENT_SECRET environment variable containing the client_secret.json content is needed.
|
53
|
+
DOC
|
54
|
+
parser.on("-e", "--export-all-sheets", TrueClass, export_all_option)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.merge_policy_option(parser)
|
58
|
+
merge_policy_option = <<~DOC
|
59
|
+
Merge specified csv (or sheets from --export-all) instead of exporting each csv.
|
60
|
+
\treplace: if a key is already defined, replace its value.
|
61
|
+
\tkeep: if a key is already defined, keep the previous value.
|
62
|
+
DOC
|
63
|
+
parser.on("-m", "--merge-policy POLICY", Interactors::MergeWordings::MERGE_POLICIES, merge_policy_option)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.platforms_option(parser)
|
67
|
+
platforms_option = <<~DOC
|
68
|
+
PLATFORMS is a comma separated list.
|
69
|
+
\tOnly generate localisation files for the specified platforms.
|
70
|
+
\tSupported platforms : #{Entities::Platform::SUPPORTED_PLATFORMS.to_sentence}
|
71
|
+
DOC
|
72
|
+
parser.on("-o", "--only PLATFORMS", Array, platforms_option)
|
73
|
+
end
|
61
74
|
end
|
62
75
|
end
|
@@ -5,6 +5,7 @@ module AdLocalize
|
|
5
5
|
DEFAULTS = {
|
6
6
|
locales: [],
|
7
7
|
bypass_empty_values: false,
|
8
|
+
auto_escape_percent: false,
|
8
9
|
csv_paths: [],
|
9
10
|
merge_policy: Interactors::MergeWordings::DEFAULT_POLICY,
|
10
11
|
output_path: Pathname.new('exports'),
|
@@ -21,6 +22,7 @@ module AdLocalize
|
|
21
22
|
attr_reader(
|
22
23
|
:locales,
|
23
24
|
:bypass_empty_values,
|
25
|
+
:auto_escape_percent,
|
24
26
|
:csv_paths,
|
25
27
|
:merge_policy,
|
26
28
|
:output_path,
|
@@ -35,6 +37,7 @@ module AdLocalize
|
|
35
37
|
def initialize
|
36
38
|
@locales = DEFAULTS[:locales]
|
37
39
|
@bypass_empty_values = DEFAULTS[:bypass_empty_values]
|
40
|
+
@auto_escape_percent = DEFAULTS[:auto_escape_percent]
|
38
41
|
@csv_paths = DEFAULTS[:csv_paths]
|
39
42
|
@merge_policy = DEFAULTS[:merge_policy]
|
40
43
|
@output_path = DEFAULTS[:output_path]
|
@@ -56,6 +59,10 @@ module AdLocalize
|
|
56
59
|
@bypass_empty_values = [true, 'true'].include?(value)
|
57
60
|
end
|
58
61
|
|
62
|
+
def auto_escape_percent=(value)
|
63
|
+
@auto_escape_percent = [true, 'true'].include?(value)
|
64
|
+
end
|
65
|
+
|
59
66
|
def csv_paths=(value)
|
60
67
|
return unless value.is_a? Array
|
61
68
|
|
@@ -119,6 +126,7 @@ module AdLocalize
|
|
119
126
|
def to_s
|
120
127
|
"locales: #{locales}, " \
|
121
128
|
"bypass_empty_values: #{bypass_empty_values}, " \
|
129
|
+
"auto_escape_percent: #{auto_escape_percent}, " \
|
122
130
|
"csv_paths: #{csv_paths}, " \
|
123
131
|
"merge_policy: #{merge_policy}, " \
|
124
132
|
"output_path: #{output_path}, " \
|
@@ -2,10 +2,21 @@
|
|
2
2
|
module AdLocalize
|
3
3
|
module Sanitizers
|
4
4
|
class IOSSanitizer
|
5
|
+
attr_accessor :should_auto_escape_percent
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@should_auto_escape_percent = false
|
9
|
+
end
|
10
|
+
|
5
11
|
def sanitize(value:)
|
6
12
|
return if value.blank?
|
7
13
|
|
8
|
-
value.gsub(/(?<!\\)\"/, "\\\"")
|
14
|
+
processed_value = value.gsub(/(?<!\\)\"/, "\\\"")
|
15
|
+
if @should_auto_escape_percent
|
16
|
+
# we should escape % sign when not used as formatting function (see: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html)
|
17
|
+
processed_value = processed_value.gsub(/%(?!((\d+\$)?([a-zA-Z]|@)))/, '%%')
|
18
|
+
end
|
19
|
+
processed_value
|
9
20
|
end
|
10
21
|
end
|
11
22
|
end
|
@@ -13,6 +13,10 @@ module AdLocalize
|
|
13
13
|
render_template(template_path: template_path, variable_binding: variable_binding)
|
14
14
|
end
|
15
15
|
|
16
|
+
def configure(export_request:)
|
17
|
+
# override if you need flags from export_request
|
18
|
+
end
|
19
|
+
|
16
20
|
protected
|
17
21
|
|
18
22
|
TEMPLATES_DIRECTORY = __dir__ + "/../templates"
|
data/lib/ad_localize/version.rb
CHANGED
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: 6.
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edouard Siegel
|
@@ -21,7 +21,7 @@ authors:
|
|
21
21
|
autorequire:
|
22
22
|
bindir: exe
|
23
23
|
cert_chain: []
|
24
|
-
date: 2023-
|
24
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
302
|
- !ruby/object:Gem::Version
|
303
303
|
version: '0'
|
304
304
|
requirements: []
|
305
|
-
rubygems_version: 3.
|
305
|
+
rubygems_version: 3.4.10
|
306
306
|
signing_key:
|
307
307
|
specification_version: 4
|
308
308
|
summary: AdLocalize helps with mobile and web applications wording
|