ad_localize 3.5.0 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -0
  3. data/Gemfile.lock +40 -17
  4. data/README.md +148 -136
  5. data/ad_localize.gemspec +3 -2
  6. data/bin/console +1 -0
  7. data/exe/ad_localize +1 -1
  8. data/lib/ad_localize.rb +51 -11
  9. data/lib/ad_localize/ad_logger.rb +22 -9
  10. data/lib/ad_localize/cli.rb +10 -0
  11. data/lib/ad_localize/constant.rb +2 -21
  12. data/lib/ad_localize/entities/key.rb +74 -0
  13. data/lib/ad_localize/entities/locale_wording.rb +60 -0
  14. data/lib/ad_localize/entities/translation.rb +20 -0
  15. data/lib/ad_localize/entities/wording.rb +24 -0
  16. data/lib/ad_localize/interactors/execute_export_request.rb +43 -0
  17. data/lib/ad_localize/interactors/export_csv_files.rb +17 -0
  18. data/lib/ad_localize/interactors/export_g_spreadsheet.rb +55 -0
  19. data/lib/ad_localize/interactors/export_wording.rb +27 -0
  20. data/lib/ad_localize/interactors/merge_wordings.rb +43 -0
  21. data/lib/ad_localize/interactors/platforms/export_android_locale_wording.rb +39 -0
  22. data/lib/ad_localize/interactors/platforms/export_ios_locale_wording.rb +62 -0
  23. data/lib/ad_localize/interactors/platforms/export_json_locale_wording.rb +23 -0
  24. data/lib/ad_localize/interactors/platforms/export_platform_factory.rb +44 -0
  25. data/lib/ad_localize/interactors/platforms/export_properties_locale_wording.rb +29 -0
  26. data/lib/ad_localize/interactors/platforms/export_yaml_locale_wording.rb +23 -0
  27. data/lib/ad_localize/mappers/android_translation_mapper.rb +18 -0
  28. data/lib/ad_localize/mappers/csv_path_to_wording.rb +76 -0
  29. data/lib/ad_localize/mappers/ios_translation_mapper.rb +12 -0
  30. data/lib/ad_localize/mappers/locale_wording_to_hash.rb +25 -0
  31. data/lib/ad_localize/mappers/options_to_export_request.rb +28 -0
  32. data/lib/ad_localize/mappers/translation_group_mapper.rb +14 -0
  33. data/lib/ad_localize/mappers/translation_mapper.rb +30 -0
  34. data/lib/ad_localize/mappers/value_range_to_wording.rb +69 -0
  35. data/lib/ad_localize/option_handler.rb +30 -57
  36. data/lib/ad_localize/repositories/file_system_repository.rb +13 -0
  37. data/lib/ad_localize/repositories/g_sheets_repository.rb +44 -0
  38. data/lib/ad_localize/requests/export_request.rb +77 -0
  39. data/lib/ad_localize/requests/g_spreadsheet_options.rb +47 -0
  40. data/lib/ad_localize/requests/merge_policy.rb +28 -0
  41. data/lib/ad_localize/serializers/info_plist_serializer.rb +27 -0
  42. data/lib/ad_localize/serializers/json_serializer.rb +13 -0
  43. data/lib/ad_localize/serializers/localizable_strings_serializer.rb +27 -0
  44. data/lib/ad_localize/serializers/localizable_stringsdict_serializer.rb +35 -0
  45. data/lib/ad_localize/serializers/properties_serializer.rb +25 -0
  46. data/lib/ad_localize/serializers/strings_serializer.rb +33 -0
  47. data/lib/ad_localize/serializers/with_template.rb +19 -0
  48. data/lib/ad_localize/serializers/yaml_serializer.rb +13 -0
  49. data/lib/ad_localize/templates/android/strings.xml.erb +19 -0
  50. data/lib/ad_localize/templates/ios/InfoPlist.strings.erb +3 -0
  51. data/lib/ad_localize/templates/ios/Localizable.strings.erb +3 -0
  52. data/lib/ad_localize/templates/ios/Localizable.stringsdict.erb +41 -0
  53. data/lib/ad_localize/templates/properties/template.properties.erb +3 -0
  54. data/lib/ad_localize/version.rb +1 -1
  55. data/lib/ad_localize/view_models/translation_group_view_model.rb +15 -0
  56. data/lib/ad_localize/view_models/translation_view_model.rb +19 -0
  57. metadata +68 -13
  58. data/Makefile +0 -11
  59. data/lib/ad_localize/csv_file_manager.rb +0 -64
  60. data/lib/ad_localize/csv_parser.rb +0 -165
  61. data/lib/ad_localize/platform/android_formatter.rb +0 -70
  62. data/lib/ad_localize/platform/ios_formatter.rb +0 -143
  63. data/lib/ad_localize/platform/json_formatter.rb +0 -17
  64. data/lib/ad_localize/platform/platform_formatter.rb +0 -109
  65. data/lib/ad_localize/platform/yml_formatter.rb +0 -19
  66. data/lib/ad_localize/runner.rb +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e814ce7a840c1c9da11fc1f34574929e7ad4805f410319b3c6f79e8f8027024e
4
- data.tar.gz: 65864cb313e53121a7d9fc06028f944853f3842ee3eb060b7ccdff099b3477a2
3
+ metadata.gz: b482ce9a7080380dfef2db59f93af1752fa1b570764393bfc163a10bec1fa81c
4
+ data.tar.gz: d1a1a841fba380486a618627541d9a50ce1c322a9695ce3ac904faf259458950
5
5
  SHA512:
6
- metadata.gz: f84b9f8ef16b073e98c4e41a87575e35c5881586e1bebe44c226005bbdcf3b9704bc6b869ae4cb6fb4162866560a2e6c69e154b505b058f6923d852093ba1624
7
- data.tar.gz: 02fe755026fad1ef4bca910a6457ef7d2806b40077fe3acbfc4d7b469372b7382bb7c98098c3220d6fc977cef40255e2c3cf85cc8f927cc1b3f78d9bf7ff31b7
6
+ metadata.gz: 717d03d8cacc640e384cd1cf7c961a8e52ca8e9bc4545ee2ba6d92e4f9f698112b491640bf53b99dbe159b659c037e4a6154caf632e4fe7f908394a0115ff238
7
+ data.tar.gz: 0703ee04049d0a12c6b111ea623759dc1da8d9a820aec1f0ed992fffdb967a014337a4b5cda92d74b2b600bd0d8200e7c1f4264ab3a1f90e0946d1f154e5be5e
@@ -4,6 +4,68 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [4.0.3] - 2020-10-27
8
+ ### Fixed
9
+ - Fix CSV detection and remove dependency to MimeType gem
10
+ - Fix drive key detection in options
11
+
12
+ ## [4.0.2] - 2020-10-26
13
+ ### Fixed
14
+ - Use percent HTML char for escaping '%' on android. [#49](https://github.com/applidium/ad_localize/pull/49) by [flolom](https://github.com/flolom)
15
+
16
+ ## [4.0.1] - 2020-10-19
17
+ ### Fixed
18
+ - delete downloaded files even when any of them is a CSV file
19
+
20
+ ## [4.0.0] - 2020-10-19
21
+ ### Breaking change
22
+ - Precedence to csv files. Only CSV files will be exported if both csv file and google spreadsheet are provided
23
+ - 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
24
+ - 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)
25
+
26
+ ### Changed
27
+ - it is now possible to provide an output path path that does not exist
28
+ - if a service account configuration is provided, there won't be any files downloaded
29
+ - it is now possible to provide a sheet id list
30
+ - `ActiveSupport::TestCase` is now the base class of test classes
31
+ - Only global constants are in the constant class
32
+ - Replaced the Runner class file by a cli class
33
+ - tests for ad_localize class are restricted to the minimum
34
+ - No more file generated when there are no data to export
35
+ - Less verbose logs. Now, they only describe the different steps of the export process
36
+ - do not add `InfoPlist` translations to android `strings.xml`
37
+
38
+ ### Added
39
+ - -e, -export_all_sheets option export all sheets from a spreadsheet by [@sjcqs](https://github.com/sjcqs)
40
+ - -m, --merge-option to select the merge policy (`keep` or `replace`) by [@sjcqs](https://github.com/sjcqs)
41
+ - it is now possible to select which locales you want to export
42
+ - key class is tested
43
+ - option handler is tested
44
+ - execute_export_request is tested (only csv)
45
+ - export request is tested
46
+ - dedicated folder for fixture files
47
+ - add ability to use AdLocalize in a Ruby program
48
+ - add documentation for JSON and YAML support. Fixes [#23](https://github.com/applidium/ad_localize/issues/23)
49
+
50
+ ### Fixed
51
+ - comments will now be added to iOS and Android plural files
52
+ - do not remove existing files in export output folder. Fixes [#40](https://github.com/applidium/ad_localize/issues/40)
53
+
54
+ ### Removed
55
+ - 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
56
+ - no more substitution of empty wording with by "Missing Translation" when using the option -d
57
+ - no more Makefile, the Rakefile is sufficient. Use `bundle exec rake -T` to display the available commands
58
+ - no more check for ordered interpolation variables in translations
59
+
60
+ ## [3.6.0] - 2020-06-23
61
+ ### Added
62
+ - add documentation for service account usage by [@sjcqs](https://github.com/sjcqs)
63
+ - add compatibility with activesupport 6 by [@Hugo-Hache](https://github.com/Hugo-Hache)
64
+
65
+ ### Changed
66
+
67
+ ### Fixed
68
+
7
69
  ## [3.5.0] - 2020-05-12
8
70
  ### Added
9
71
  - 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)
@@ -1,42 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ad_localize (3.4.0)
5
- activesupport (>= 4.2.10)
4
+ ad_localize (4.0.3)
5
+ activesupport (>= 5.2, < 7.0)
6
6
  colorize (~> 0.8)
7
- googleauth (~> 0.12.0)
8
- nokogiri (~> 1.8, >= 1.8.2)
7
+ google-api-client (~> 0.34)
8
+ googleauth (~> 0.12)
9
+ nokogiri (~> 1.10)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- activesupport (6.0.2.2)
14
+ activesupport (6.0.3.4)
14
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
16
  i18n (>= 0.7, < 2)
16
17
  minitest (~> 5.1)
17
18
  tzinfo (~> 1.1)
18
- zeitwerk (~> 2.2)
19
+ zeitwerk (~> 2.2, >= 2.2.2)
19
20
  addressable (2.7.0)
20
21
  public_suffix (>= 2.0.2, < 5.0)
21
22
  ansi (1.5.0)
22
23
  builder (3.2.4)
23
24
  byebug (11.1.3)
24
25
  colorize (0.8.1)
25
- concurrent-ruby (1.1.6)
26
+ concurrent-ruby (1.1.7)
27
+ declarative (0.0.20)
28
+ declarative-option (0.1.0)
26
29
  diffy (3.3.0)
27
- faraday (0.17.3)
30
+ faraday (1.1.0)
28
31
  multipart-post (>= 1.2, < 3)
29
- googleauth (0.12.0)
32
+ ruby2_keywords
33
+ google-api-client (0.46.2)
34
+ addressable (~> 2.5, >= 2.5.1)
35
+ googleauth (~> 0.9)
36
+ httpclient (>= 2.8.1, < 3.0)
37
+ mini_mime (~> 1.0)
38
+ representable (~> 3.0)
39
+ retriable (>= 2.0, < 4.0)
40
+ rexml
41
+ signet (~> 0.12)
42
+ googleauth (0.14.0)
30
43
  faraday (>= 0.17.3, < 2.0)
31
44
  jwt (>= 1.4, < 3.0)
32
45
  memoist (~> 0.16)
33
46
  multi_json (~> 1.11)
34
47
  os (>= 0.9, < 2.0)
35
48
  signet (~> 0.14)
36
- i18n (1.8.2)
49
+ httpclient (2.8.3)
50
+ i18n (1.8.5)
37
51
  concurrent-ruby (~> 1.0)
38
- jwt (2.1.0)
52
+ jwt (2.2.2)
39
53
  memoist (0.16.2)
54
+ mini_mime (1.0.2)
40
55
  mini_portile2 (2.4.0)
41
56
  minitest (5.14.0)
42
57
  minitest-reporters (1.4.2)
@@ -44,14 +59,21 @@ GEM
44
59
  builder
45
60
  minitest (>= 5.0)
46
61
  ruby-progressbar
47
- multi_json (1.14.1)
48
- multipart-post (2.0.0)
49
- nokogiri (1.10.9)
62
+ multi_json (1.15.0)
63
+ multipart-post (2.1.1)
64
+ nokogiri (1.10.10)
50
65
  mini_portile2 (~> 2.4.0)
51
- os (1.1.0)
52
- public_suffix (2.0.5)
66
+ os (1.1.1)
67
+ public_suffix (4.0.6)
53
68
  rake (12.3.3)
69
+ representable (3.0.4)
70
+ declarative (< 0.1.0)
71
+ declarative-option (< 0.2.0)
72
+ uber (< 0.2.0)
73
+ retriable (3.1.2)
74
+ rexml (3.2.4)
54
75
  ruby-progressbar (1.10.1)
76
+ ruby2_keywords (0.0.2)
55
77
  signet (0.14.0)
56
78
  addressable (~> 2.3)
57
79
  faraday (>= 0.17.3, < 2.0)
@@ -60,7 +82,8 @@ GEM
60
82
  thread_safe (0.3.6)
61
83
  tzinfo (1.2.7)
62
84
  thread_safe (~> 0.1)
63
- zeitwerk (2.3.0)
85
+ uber (0.1.0)
86
+ zeitwerk (2.4.0)
64
87
 
65
88
  PLATFORMS
66
89
  ruby
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # AdLocalize
2
2
 
3
- The purpose of this gem is to automatically generate wording files from a csv input (local file or google spreadsheet). It is a useful tool when working on a mobile application or a SPA.
3
+ The purpose of this gem is to automatically generate wording files from a CSV input (CSV file or Google Spreadsheet).
4
+ It supports iOS, Android, JSON, YAML and Java Properties.
5
+ It is a useful tool when working on a mobile application or a SPA.
4
6
 
5
7
  ## Installation
6
8
 
@@ -26,42 +28,86 @@ $ gem install ad_localize
26
28
 
27
29
  * Display help
28
30
  ```
29
- $ bundle exec ad_localize -h
31
+ $ ad_localize -h
30
32
  ```
31
33
 
32
- * Export wording from a google spreadsheet, using the file key. Make sure to enable _Allow external access_ in sharing options.
34
+ * Export wording from a google spreadsheet, default tab. The spreadsheet key and sheet_id are available in the spreadsheet url. For example `https://docs.google.com/spreadsheets/d/<your-spreadsheet-drive-key>/edit#gid=<sheet-id>`.
33
35
  ```
34
- $ bundle exec ad_localize -k <your-spreadsheet-drive-key>
36
+ $ ad_localize -k <your-spreadsheet-drive-key>
35
37
  ```
36
38
 
37
- * Export wording from a google spreadsheet, using the file key and specifying a sheet (useful when your file has multiple sheets)
39
+ * Export wording from a set of google spreadsheet tabs.
38
40
  ```
39
- $ bundle exec ad_localize -k <your-spreadsheet-drive-key> -s <your-specific-sheet-id>
41
+ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
40
42
  ```
41
43
 
42
- * Export wording from a private google spreadsheet using an authorized google account
44
+ * Export wording from all sheets in a google spreadsheet. It requires a [Google Cloud Service Account](#using-a-google-cloud-service-account).
43
45
  ```
44
- $ export GCLOUD_CLIENT_SECRET=$(cat <client-secret.json>)
45
- $ bundle exec ad_localize -k <your-spreadsheet-drive-key> -a
46
+ $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secret.json>) ad_localize -k <your-spreadsheet-drive-key> -e
46
47
  ```
47
48
 
48
49
  * Only generate wording files for the specified platforms
49
50
  ```
50
- $ bundle exec ad_localize -o ios
51
+ $ ad_localize -o ios
51
52
  ```
52
53
 
53
54
  * Choose the path of the output directory
54
55
  ```
55
- $ bundle exec ad_localize -t <path-to-the-output-directory>
56
+ $ ad_localize -t <path-to-the-output-directory>
56
57
  ```
57
58
 
58
- * Run in debug mode. In this mode, logs are more verbose and missing values are replaced with "<Missing Translation>"
59
+ * Run in debug mode. In this mode, logs are more verbose
59
60
  ```
60
- $ bundle exec ad_localize -d
61
+ $ ad_localize -d
61
62
  ```
62
63
 
63
- ### CSV file
64
- #### General syntax rules
64
+ ### In a Ruby program
65
+ 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.
66
+
67
+ Here is an example of how to use it to produce the same output as the command line.
68
+ If you want more examples, please open a documentation issue.
69
+
70
+ ```Ruby
71
+ require 'ad_localize'
72
+ # create optional google spreasheet options
73
+ g_spreadsheet_options = AdLocalize::Requests::GSpreadsheetOptions.new(spreadsheet_id: 'some_id', sheet_ids: ['first', 'second'], service_account_config: ENV['GCLOUD_CLIENT_SECRET'])
74
+ # create export request
75
+ export_request = AdLocalize::Requests::ExportRequest.new(g_spreadsheet_options: g_spreadsheet_options, verbose: true)
76
+ # execute request
77
+ AdLocalize::Interactors::ExecuteExportRequest.new.call(export_request: export_request)
78
+ ```
79
+
80
+ ## Accessing a google spreadsheet
81
+ ### Share to anyone with the link
82
+
83
+ If you do not have high security concerns, the simplest way to access a google spreadsheet is to allow **anyone** with the link to **view** it and enable the `Viewers and commenters can see the option to download, print, and copy` option in the spreadsheet sharing settings.
84
+
85
+ ### Use a Google Cloud Service Account
86
+
87
+ To use a private google spreasheet you need to use a Google Cloud Service Account. Here are the steps to follow :
88
+ 1. Create a GCloud Service Account:
89
+ - Go to [Google Cloud Console](https://console.cloud.google.com/)
90
+ - Either create a new project or use an existing one (when using Firebase, a GCloud project is created)
91
+ - Go to *IAM & Admin / Service Account* and create a new service account.
92
+ - Store the created `client-secret.json` (in a password manager for example)
93
+ 2. Enable Google Spreadsheet API for the project
94
+ - Go to *API / Library* and enable the **Google Spreadsheet API** there.
95
+ 3. Add the service account to a spreadsheet.
96
+ - In *IAM & Admin / Service Account*, the service account's email is listed. Invite it to the spreadsheet to export.
97
+
98
+ ```
99
+ $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>) ad_localize -k # one way
100
+ $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>) ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list> # another way
101
+ ```
102
+
103
+ ```
104
+ $ export GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>)
105
+ $ ad_localize -k <your-spreadsheet-drive-key> # one way
106
+ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list> # another way
107
+ ```
108
+
109
+ ## Wording syntax
110
+ ### General syntax rules
65
111
 
66
112
  | key | fr | en |
67
113
  | --- | --- | --- |
@@ -69,32 +115,96 @@ $ bundle exec ad_localize -d
69
115
  | favorites | Mes favoris | My favorites |
70
116
  | from_to | du %1$@ au %2$@ | from %1$@ to %2$@ |
71
117
 
72
- - Any column after the `key` column will be considered as a locale column (except from the optional `comment columns)
73
- - Keys should be written in Android format : [a-z0-9_]+
74
- - Format specifiers must be numeroted if there are more than one in a translation string (eg: "%1$@ %2$@'s report").
75
-
118
+ - Any column after the `key` column will be considered as a locale column (except from the optional `comment` columns)
119
+ - Keys should contain only letter, number, underscore and dot : [a-z0-9_.]+.
120
+ - Format specifiers must be numeroted if there are more than one in a translation string (eg: `"%1$@ %2$@'s report"`).
76
121
 
77
- #### Comment columns
122
+ ### Comments
78
123
 
79
- In iOS (and only iOS) you can add a comment to a missing translation.
124
+ _Only for Android and iOS_
80
125
 
81
- | key | fr | comment fr | en | comment en |
82
- | --- | --- | --- | --- | --- |
83
- | player_time_live | Live | bypass-unused-error | Live | bypass-unused-error |
84
- | seconds | secondes | | seconds | bypass-untranslated-error |
126
+ To add comments for iOS or Android, simply add a comment column using the naming convention `comment <locale>`.
127
+ Comments are available in `strings.xml`, `Localizable.strings`, `Localizable.stringsdict`, `InfoPlist.strings`. Here is an example for `InfoPlist.strings` :
85
128
 
86
- The comment will be written in the output files such as below:
129
+ | key | en | comment en |
130
+ | --- | --- | --- |
131
+ | player_time_live | Live | bypass-unused-error |
132
+ | seconds | seconds | bypass-untranslated-error |
87
133
 
88
134
  ```
89
135
  "player_time_live" = "Live"; // bypass-unused-error
90
136
  "seconds" = "seconds"; // bypass-untranslated-error
91
137
  ```
92
138
 
139
+ ### Key with plural notation
140
+
141
+ _Only for Android and iOS_
142
+
143
+ Syntax for plural keys in the CSV file: `key##{text}`.
144
+
145
+ | key | fr |
146
+ | --- | --- |
147
+ | assess_rate_trip_voiceover##{one} | Rate %1$@ star |
148
+ | assess_rate_trip_voiceover##{other} | Rate %1$@ stars |
149
+
150
+ ### String interpolation mapping
151
+
152
+ _Only for Android_
153
+
154
+ If you want to share a spreadsheet between iOS and Android, you can write the wording using the iOS string interpolation convention.
155
+ The translation to android convention will be done automagically.
156
+
157
+ ### Adaptive strings
158
+
159
+ _Only for iOS_
160
+
161
+ Syntax for [adaptive keys](https://developer.apple.com/documentation/foundation/nsstring/1413104-variantfittingpresentationwidth) in the CSV file: `key##{number}`.
162
+
163
+ | key | fr |
164
+ | --- | --- |
165
+ | start_countdown##{20} | Start |
166
+ | start_countdown##{25} | Start countdown |
167
+ | start_countdown##{50} | Start countdown |
168
+
169
+ ### InfoPlist.strings
170
+
171
+ _Only for iOS._
172
+
173
+ Every key that matches the following formats will be added to the `InfoPlist.strings` file instead of `Localizable.strings`:
174
+ * `NS...UsageDescription`
175
+ * `CF...Name`
176
+
177
+ ### Nested wording
178
+
179
+ _Only for YAML and JSON_
180
+
181
+ For these two platforms it is common to have nested wording files, either to handle plural or to group wording by sections. To handle this behavior in a simple way you should use dots in the key to separate the different levels. For example :
182
+
183
+ | key | fr |
184
+ | --- | --- |
185
+ | login.password | mot de passe |
186
+ | login.email | email |
187
+
188
+ ```json
189
+ {"login":{"password":"mot de passe","email":"email"}}
190
+ ```
191
+
192
+ ```yaml
193
+ fr:
194
+ login:
195
+ password: "mot de passe"
196
+ email: "email"
197
+ ```
198
+
199
+
93
200
  ## Output
94
201
 
95
- The output folder name is `exports` and it contains a folder for each platform and each locale. In the best case, you just have to replace your existing files with the new ones.
202
+ The default output folder name is `exports`.
203
+ If your export is for multiple platforms there will be an intermediate folder for each platform, otherwise the wording files (and folders) will directly be generated in the export folder.
204
+ Any existing file will be overriden.
205
+ You can see examples of generated files in `test/fixtures/export_references/`
96
206
 
97
- Eg:
207
+ Here an export tree example for all supported platforms in `fr` and `en`:
98
208
  ```
99
209
  exports/
100
210
  ├── android
@@ -104,130 +214,32 @@ exports/
104
214
  │   └── strings.xml
105
215
  ├── ios
106
216
  │   ├── en.lproj
217
+ │   │   ├── InfoPlist.strings
107
218
  │   │   ├── Localizable.strings
108
- │   │   ├── Localizable.stringsdict
109
- | | └── InfoPlist.strings
110
- └── fr.lproj
219
+ │   │   └── Localizable.stringsdict
220
+ │   └── fr.lproj
221
+    ├── InfoPlist.strings
111
222
  │   ├── Localizable.strings
112
- │   ├── Localizable.stringsdict
113
- | └── InfoPlist.strings
223
+ │   └── Localizable.stringsdict
114
224
  ├── json
115
225
  │   ├── en.json
116
226
  │   └── fr.json
227
+ ├── properties
228
+ │   ├── en.properties
229
+ │   └── fr.properties
117
230
  └── yml
118
231
  ├── en.yml
119
232
  └── fr.yml
120
233
  ```
121
234
 
122
- NB: If you select only one platform, the wording files will directly be generated in the output path. The output path is the `exports` folder in the current directory by default and you can change it using the option `-o`.
123
-
124
- ## Plurals
125
-
126
- Plurals are supported for iOS and Android.
127
-
128
- Syntax for plural keys in the CSV file:
129
-
130
- key##{few}
131
- key##{one}
132
- key##{other}
133
-
134
-
135
- Sample of Android output in strings.xml
136
-
137
- ```xml
138
- <resources>
139
- <plurals name="cake">
140
- <item quantity=["zero"|"one"]>gateau</item>
141
- <item quantity="other">gateaux</item>
142
- </plural>
143
- </resources>
144
- ```
145
-
146
- Sample of iOS output in .stringsdict
147
-
148
- ```xml
149
- <?xml version="1.0" encoding="UTF-8"?>
150
- <plist>
151
- <dict>
152
- <key>traveller_type_child_title</key>
153
- <dict>
154
- <key>NSStringLocalizedFormatKey</key>
155
- <string>%#@key@</string>
156
- <key>key</key>
157
- <dict>
158
- <key>NSStringFormatSpecTypeKey</key>
159
- <string>NSStringPluralRuleType</string>
160
- <key>NSStringFormatValueTypeKey</key>
161
- <string>d</string>
162
- <key>zero</key>
163
- <string/>
164
- <key>one</key>
165
- <string>1 enfant</string>
166
- <key>two</key>
167
- <string/>
168
- <key>few</key>
169
- <string/>
170
- <key>many</key>
171
- <string/>
172
- <key>other</key>
173
- <string>%d enfants</string>
174
- </dict>
175
- </dict>
176
- </dict>
177
- </plist>
178
- ```
179
-
180
- ## InfoPlist.strings
181
-
182
- _Only for iOS._
183
-
184
- Every key that matches the following formats will be added to the `InfoPlist.strings` file instead of `Localizable.strings`:
185
- * `NS...UsageDescription`
186
- * `CF...Name`
187
-
188
- Source: https://developer.apple.com/documentation/bundleresources/information_property_list
189
-
190
- ## Adaptive strings
191
-
192
- _Only for iOS._
193
-
194
- Syntax for adaptive keys in the CSV file:
195
-
196
- key##{20}
197
- key##{25}
198
- key##{50}
199
-
200
-
201
- Sample of iOS output in .stringsdict
202
-
203
- ```xml
204
- <?xml version="1.0" encoding="UTF-8"?>
205
- <plist>
206
- <dict>
207
- <key>start_countdown</key>
208
- <dict>
209
- <key>NSStringVariableWidthRuleType</key>
210
- <dict>
211
- <key>20</key>
212
- <string>Start</string>
213
- <key>25</key>
214
- <string>Start countdown</string>
215
- <key>50</key>
216
- <string>Start countdown</string>
217
- </dict>
218
- </dict>
219
- </dict>
220
- </plist>
221
- ```
222
-
223
- Source: https://developer.apple.com/documentation/foundation/nsstring/1413104-variantfittingpresentationwidth
224
-
225
235
  ## Development
226
236
 
227
237
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
228
238
 
229
239
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
230
240
 
241
+ To see all available commands run `bundle exec rake -T` .
242
+
231
243
  ## Contributing
232
244
 
233
245
  Bug reports and pull requests are welcome on GitHub at https://github.com/applidium/ad_localize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.