ad_localize 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +20 -0
  3. data/.gitignore +2 -1
  4. data/CHANGELOG.md +71 -0
  5. data/Gemfile.lock +101 -0
  6. data/README.md +152 -95
  7. data/ad_localize.gemspec +10 -5
  8. data/bin/console +1 -0
  9. data/exe/ad_localize +1 -1
  10. data/lib/ad_localize.rb +52 -9
  11. data/lib/ad_localize/ad_logger.rb +22 -9
  12. data/lib/ad_localize/cli.rb +10 -0
  13. data/lib/ad_localize/constant.rb +2 -21
  14. data/lib/ad_localize/entities/key.rb +74 -0
  15. data/lib/ad_localize/entities/locale_wording.rb +60 -0
  16. data/lib/ad_localize/entities/translation.rb +20 -0
  17. data/lib/ad_localize/entities/wording.rb +24 -0
  18. data/lib/ad_localize/interactors/execute_export_request.rb +43 -0
  19. data/lib/ad_localize/interactors/export_csv_files.rb +17 -0
  20. data/lib/ad_localize/interactors/export_g_spreadsheet.rb +55 -0
  21. data/lib/ad_localize/interactors/export_wording.rb +27 -0
  22. data/lib/ad_localize/interactors/merge_wordings.rb +43 -0
  23. data/lib/ad_localize/interactors/platforms/export_android_locale_wording.rb +39 -0
  24. data/lib/ad_localize/interactors/platforms/export_ios_locale_wording.rb +62 -0
  25. data/lib/ad_localize/interactors/platforms/export_json_locale_wording.rb +23 -0
  26. data/lib/ad_localize/interactors/platforms/export_platform_factory.rb +44 -0
  27. data/lib/ad_localize/interactors/platforms/export_properties_locale_wording.rb +29 -0
  28. data/lib/ad_localize/interactors/platforms/export_yaml_locale_wording.rb +23 -0
  29. data/lib/ad_localize/mappers/android_translation_mapper.rb +18 -0
  30. data/lib/ad_localize/mappers/csv_path_to_wording.rb +76 -0
  31. data/lib/ad_localize/mappers/ios_translation_mapper.rb +12 -0
  32. data/lib/ad_localize/mappers/locale_wording_to_hash.rb +25 -0
  33. data/lib/ad_localize/mappers/options_to_export_request.rb +28 -0
  34. data/lib/ad_localize/mappers/translation_group_mapper.rb +14 -0
  35. data/lib/ad_localize/mappers/translation_mapper.rb +30 -0
  36. data/lib/ad_localize/mappers/value_range_to_wording.rb +69 -0
  37. data/lib/ad_localize/option_handler.rb +30 -52
  38. data/lib/ad_localize/repositories/file_system_repository.rb +13 -0
  39. data/lib/ad_localize/repositories/g_sheets_repository.rb +44 -0
  40. data/lib/ad_localize/requests/export_request.rb +77 -0
  41. data/lib/ad_localize/requests/g_spreadsheet_options.rb +47 -0
  42. data/lib/ad_localize/requests/merge_policy.rb +28 -0
  43. data/lib/ad_localize/serializers/info_plist_serializer.rb +27 -0
  44. data/lib/ad_localize/serializers/json_serializer.rb +13 -0
  45. data/lib/ad_localize/serializers/localizable_strings_serializer.rb +27 -0
  46. data/lib/ad_localize/serializers/localizable_stringsdict_serializer.rb +35 -0
  47. data/lib/ad_localize/serializers/properties_serializer.rb +25 -0
  48. data/lib/ad_localize/serializers/strings_serializer.rb +33 -0
  49. data/lib/ad_localize/serializers/with_template.rb +19 -0
  50. data/lib/ad_localize/serializers/yaml_serializer.rb +13 -0
  51. data/lib/ad_localize/templates/android/strings.xml.erb +19 -0
  52. data/lib/ad_localize/templates/ios/InfoPlist.strings.erb +3 -0
  53. data/lib/ad_localize/templates/ios/Localizable.strings.erb +3 -0
  54. data/lib/ad_localize/templates/ios/Localizable.stringsdict.erb +41 -0
  55. data/lib/ad_localize/templates/properties/template.properties.erb +3 -0
  56. data/lib/ad_localize/version.rb +1 -1
  57. data/lib/ad_localize/view_models/translation_group_view_model.rb +15 -0
  58. data/lib/ad_localize/view_models/translation_view_model.rb +19 -0
  59. metadata +103 -27
  60. data/lib/ad_localize/csv_file_manager.rb +0 -47
  61. data/lib/ad_localize/csv_parser.rb +0 -165
  62. data/lib/ad_localize/platform/android_formatter.rb +0 -70
  63. data/lib/ad_localize/platform/ios_formatter.rb +0 -138
  64. data/lib/ad_localize/platform/json_formatter.rb +0 -18
  65. data/lib/ad_localize/platform/platform_formatter.rb +0 -76
  66. data/lib/ad_localize/platform/yml_formatter.rb +0 -18
  67. data/lib/ad_localize/runner.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b67ba9ff725d7fbf76fd0d680b07573648ee51966fdbb8429e6a26a764fc5563
4
- data.tar.gz: 7ce5a08e27d50cbedd1ca1f4ffac9af1817ee8c38e97eb088d6dd7bc6d8ec5d0
3
+ metadata.gz: 1581d41a8d5a3f41dc91cf69f4b8abfdf8c2121695cf116a46c738825818cbd9
4
+ data.tar.gz: 64af1cc80f9e9247514c334e13f6252e267283e3c38ade2d3111a4deb252164b
5
5
  SHA512:
6
- metadata.gz: 0eb0c873e0d27062cc4291baab1c330224997ef3085b7474424c50d0dff8f089c40ae9f668e91f5769ce6d7c69431892435ee65a5a3073815ddbbe9bcde539be
7
- data.tar.gz: 7998404ef9a406c7421117d666fae0c3aa8bfa0f55a5fe4e5a207a7c6bc01d370de3158a47910d47205d73a266a35109ca819cf114b572fe848061454e5fad29
6
+ metadata.gz: 0ebfdd0a7746acdaa06b713c6f129b04b7a81fb0441bf5975a47b415b892dd135b87c3e99e0610a98584adb2317f4d170a64230f932db3a3c0c3ecf8d00eabee
7
+ data.tar.gz: bd9a7140d68dc5f76c6c9e0dc19342180083205079d6d4e6022c0039176ae36f9e8c50441dec84bd5ea89f6596812c998be246163c3a9942e5fd9661379c3c30
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
data/.gitignore CHANGED
@@ -9,4 +9,5 @@ ad_localize/tmp/
9
9
  .idea
10
10
  .byebug_history
11
11
  .ruby-version
12
-
12
+ pkg/
13
+ exports/
@@ -4,6 +4,77 @@ 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.0] - 2020-10-19
8
+ ### Breaking change
9
+ - Precedence to csv files. Only CSV files will be exported if both csv file and google spreadsheet are provided
10
+ - 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
11
+ - 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)
12
+
13
+ ### Changed
14
+ - it is now possible to provide an output path path that does not exist
15
+ - if a service account configuration is provided, there won't be any files downloaded
16
+ - it is now possible to provide a sheet id list
17
+ - `ActiveSupport::TestCase` is now the base class of test classes
18
+ - Only global constants are in the constant class
19
+ - Replaced the Runner class file by a cli class
20
+ - tests for ad_localize class are restricted to the minimum
21
+ - No more file generated when there are no data to export
22
+ - Less verbose logs. Now, they only describe the different steps of the export process
23
+ - do not add `InfoPlist` translations to android `strings.xml`
24
+
25
+ ### Added
26
+ - -e, -export_all_sheets option export all sheets from a spreadsheet by [@sjcqs](https://github.com/sjcqs)
27
+ - -m, --merge-option to select the merge policy (`keep` or `replace`) by [@sjcqs](https://github.com/sjcqs)
28
+ - it is now possible to select which locales you want to export
29
+ - key class is tested
30
+ - option handler is tested
31
+ - execute_export_request is tested (only csv)
32
+ - export request is tested
33
+ - dedicated folder for fixture files
34
+ - add ability to use AdLocalize in a Ruby program
35
+ - add documentation for JSON and YAML support. Fixes [#23](https://github.com/applidium/ad_localize/issues/23)
36
+
37
+ ### Fixed
38
+ - comments will now be added to iOS and Android plural files
39
+ - do not remove existing files in export output folder. Fixes [#40](https://github.com/applidium/ad_localize/issues/40)
40
+
41
+ ### Removed
42
+ - 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
43
+ - no more substitution of empty wording with by "Missing Translation" when using the option -d
44
+ - no more Makefile, the Rakefile is sufficient. Use `bundle exec rake -T` to display the available commands
45
+ - no more check for ordered interpolation variables in translations
46
+
47
+ ## [3.6.0] - 2020-06-23
48
+ ### Added
49
+ - add documentation for service account usage by [@sjcqs](https://github.com/sjcqs)
50
+ - add compatibility with activesupport 6 by [@Hugo-Hache](https://github.com/Hugo-Hache)
51
+
52
+ ### Changed
53
+
54
+ ### Fixed
55
+
56
+ ## [3.5.0] - 2020-05-12
57
+ ### Added
58
+ - 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)
59
+ - add makefile for easier testing by [@felginep](https://github.com/felginep)
60
+
61
+ ### Changed
62
+ - 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)
63
+ - 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)
64
+ - raise error when google spreadsheet key is invalid by [@felginep](https://github.com/felginep)
65
+
66
+ ### Fixed
67
+ - auto escape strings in Localizable.strings by [@felginep](https://github.com/felginep). Fixes [#26](https://github.com/applidium/ad_localize/issues/26)
68
+ - trim keys to prevent user error by [@felginep](https://github.com/felginep). Fixes [#16](https://github.com/applidium/ad_localize/issues/16)
69
+
70
+ ## [3.4.0] - 2019-02-10
71
+ ### Added
72
+ - Rails folks, [@epaillous](https://github.com/epaillous) has improved the YAML support. You can now have multi-level wording.
73
+
74
+ ## [3.3.0] - 2019-02-10
75
+ ### Added
76
+ - improve React support using keys with dots to generate nested JSON files by [@epaillous](https://github.com/epaillous)
77
+
7
78
  ## [3.2.0] - 2019-12-10
8
79
  ### Added
9
80
  - Add tests to compare reference exports by [@felginep](https://github.com/felginep)
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ad_localize (4.0.0)
5
+ activesupport (>= 5.2, < 7.0)
6
+ colorize (~> 0.8)
7
+ google-api-client (~> 0.34)
8
+ googleauth (~> 0.12)
9
+ mime-types (~> 3.3)
10
+ nokogiri (~> 1.10)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activesupport (6.0.3.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ zeitwerk (~> 2.2, >= 2.2.2)
21
+ addressable (2.7.0)
22
+ public_suffix (>= 2.0.2, < 5.0)
23
+ ansi (1.5.0)
24
+ builder (3.2.4)
25
+ byebug (11.1.3)
26
+ colorize (0.8.1)
27
+ concurrent-ruby (1.1.7)
28
+ declarative (0.0.20)
29
+ declarative-option (0.1.0)
30
+ diffy (3.3.0)
31
+ faraday (1.0.1)
32
+ multipart-post (>= 1.2, < 3)
33
+ google-api-client (0.44.1)
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
+ signet (~> 0.12)
41
+ googleauth (0.13.1)
42
+ faraday (>= 0.17.3, < 2.0)
43
+ jwt (>= 1.4, < 3.0)
44
+ memoist (~> 0.16)
45
+ multi_json (~> 1.11)
46
+ os (>= 0.9, < 2.0)
47
+ signet (~> 0.14)
48
+ httpclient (2.8.3)
49
+ i18n (1.8.5)
50
+ concurrent-ruby (~> 1.0)
51
+ jwt (2.2.2)
52
+ memoist (0.16.2)
53
+ mime-types (3.3.1)
54
+ mime-types-data (~> 3.2015)
55
+ mime-types-data (3.2020.0512)
56
+ mini_mime (1.0.2)
57
+ mini_portile2 (2.4.0)
58
+ minitest (5.14.0)
59
+ minitest-reporters (1.4.2)
60
+ ansi
61
+ builder
62
+ minitest (>= 5.0)
63
+ ruby-progressbar
64
+ multi_json (1.15.0)
65
+ multipart-post (2.1.1)
66
+ nokogiri (1.10.10)
67
+ mini_portile2 (~> 2.4.0)
68
+ os (1.1.1)
69
+ public_suffix (4.0.6)
70
+ rake (12.3.3)
71
+ representable (3.0.4)
72
+ declarative (< 0.1.0)
73
+ declarative-option (< 0.2.0)
74
+ uber (< 0.2.0)
75
+ retriable (3.1.2)
76
+ ruby-progressbar (1.10.1)
77
+ signet (0.14.0)
78
+ addressable (~> 2.3)
79
+ faraday (>= 0.17.3, < 2.0)
80
+ jwt (>= 1.5, < 3.0)
81
+ multi_json (~> 1.10)
82
+ thread_safe (0.3.6)
83
+ tzinfo (1.2.7)
84
+ thread_safe (~> 0.1)
85
+ uber (0.1.0)
86
+ zeitwerk (2.4.0)
87
+
88
+ PLATFORMS
89
+ ruby
90
+
91
+ DEPENDENCIES
92
+ ad_localize!
93
+ bundler (>= 1.12.0, < 3.0.0)
94
+ byebug (~> 11.0)
95
+ diffy (~> 3.3)
96
+ minitest (~> 5.11)
97
+ minitest-reporters (~> 1.3)
98
+ rake (~> 12.3)
99
+
100
+ BUNDLED WITH
101
+ 2.1.4
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,35 +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 drive spreadsheet, using the file key
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
- * Export wording from a google drive spreadsheet, using the file key and specifying a sheet (useful when your file has multiple sheets)
38
+
39
+ * Export wording from a set of google spreadsheet tabs.
40
+ ```
41
+ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
42
+ ```
43
+
44
+ * Export wording from all sheets in a google spreadsheet. It requires a [Google Cloud Service Account](#using-a-google-cloud-service-account).
37
45
  ```
38
- $ bundle exec ad_localize -k <your-spreadsheet-drive-key> -s <your-specific-sheet-id>
46
+ $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secret.json>) ad_localize -k <your-spreadsheet-drive-key> -e
39
47
  ```
40
48
 
41
49
  * Only generate wording files for the specified platforms
42
50
  ```
43
- $ bundle exec ad_localize -o ios
51
+ $ ad_localize -o ios
44
52
  ```
45
53
 
46
54
  * Choose the path of the output directory
47
55
  ```
48
- $ bundle exec ad_localize -t <path-to-the-output-directory>
56
+ $ ad_localize -t <path-to-the-output-directory>
57
+ ```
58
+
59
+ * Run in debug mode. In this mode, logs are more verbose
60
+ ```
61
+ $ ad_localize -d
62
+ ```
63
+
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 **Drive 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
49
101
  ```
50
102
 
51
- * Run in debug mode. In this mode, logs are more verbose and missing values are replaced with "<Missing Translation>"
52
103
  ```
53
- $ bundle exec ad_localize -d
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
54
107
  ```
55
108
 
56
- ### CSV file
57
- #### General syntax rules
109
+ ## Wording syntax
110
+ ### General syntax rules
58
111
 
59
112
  | key | fr | en |
60
113
  | --- | --- | --- |
@@ -62,31 +115,96 @@ $ bundle exec ad_localize -d
62
115
  | favorites | Mes favoris | My favorites |
63
116
  | from_to | du %1$@ au %2$@ | from %1$@ to %2$@ |
64
117
 
65
- - Any column after the `key` column will be considered as a locale column (except from the optional `comment columns)
66
- - Keys should be written in Android format : [a-z0-9_]+
67
- - Format specifiers must be numeroted if there are more than one in a translation string (eg: "%1$@ %2$@'s report").
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"`).
68
121
 
69
- #### Comment columns
122
+ ### Comments
70
123
 
71
- In iOS (and only iOS) you can add a comment to a missing translation.
124
+ _Only for Android and iOS_
72
125
 
73
- | key | fr | comment fr | en | comment en |
74
- | --- | --- | --- | --- | --- |
75
- | player_time_live | Live | bypass-unused-error | Live | bypass-unused-error |
76
- | 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` :
77
128
 
78
- 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 |
79
133
 
80
134
  ```
81
135
  "player_time_live" = "Live"; // bypass-unused-error
82
136
  "seconds" = "seconds"; // bypass-untranslated-error
83
137
  ```
84
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
+
85
200
  ## Output
86
201
 
87
- 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/`
88
206
 
89
- Eg:
207
+ Here an export tree example for all supported platforms in `fr` and `en`:
90
208
  ```
91
209
  exports/
92
210
  ├── android
@@ -96,93 +214,32 @@ exports/
96
214
  │   └── strings.xml
97
215
  ├── ios
98
216
  │   ├── en.lproj
217
+ │   │   ├── InfoPlist.strings
99
218
  │   │   ├── Localizable.strings
100
- │   │   ├── Localizable.stringsdict
101
- | | └── InfoPlist.strings
102
- └── fr.lproj
219
+ │   │   └── Localizable.stringsdict
220
+ │   └── fr.lproj
221
+    ├── InfoPlist.strings
103
222
  │   ├── Localizable.strings
104
- │   ├── Localizable.stringsdict
105
- | └── InfoPlist.strings
223
+ │   └── Localizable.stringsdict
106
224
  ├── json
107
225
  │   ├── en.json
108
226
  │   └── fr.json
227
+ ├── properties
228
+ │   ├── en.properties
229
+ │   └── fr.properties
109
230
  └── yml
110
231
  ├── en.yml
111
232
  └── fr.yml
112
233
  ```
113
234
 
114
- ## Plurals
115
-
116
- Plurals are supported for iOS and Android.
117
-
118
- Syntax for plural keys in the CSV file:
119
-
120
- key##{few}
121
- key##{one}
122
- key##{other}
123
-
124
-
125
- Sample of Android output in strings.xml
126
-
127
- ```xml
128
- <resources>
129
- <plurals name="cake">
130
- <item quantity=["zero"|"one"]>gateau</item>
131
- <item quantity="other">gateaux</item>
132
- </plural>
133
- </resources>
134
- ```
135
-
136
- Sample of iOS output in .stringsdict
137
-
138
- ```xml
139
- <?xml version="1.0" encoding="UTF-8"?>
140
- <plist>
141
- <dict>
142
- <key>traveller_type_child_title</key>
143
- <dict>
144
- <key>NSStringLocalizedFormatKey</key>
145
- <string>%#@key@</string>
146
- <key>key</key>
147
- <dict>
148
- <key>NSStringFormatSpecTypeKey</key>
149
- <string>NSStringPluralRuleType</string>
150
- <key>NSStringFormatValueTypeKey</key>
151
- <string>d</string>
152
- <key>zero</key>
153
- <string/>
154
- <key>one</key>
155
- <string>1 enfant</string>
156
- <key>two</key>
157
- <string/>
158
- <key>few</key>
159
- <string/>
160
- <key>many</key>
161
- <string/>
162
- <key>other</key>
163
- <string>%d enfants</string>
164
- </dict>
165
- </dict>
166
- </dict>
167
- </plist>
168
- ```
169
-
170
- ## InfoPlist.strings
171
-
172
- _Only for iOS._
173
-
174
- Every key that matches the following formats will be added to the `InfoPlist.strings` file instead of `Localizable.strings`:
175
- * `NS...UsageDescription`
176
- * `CF...Name`
177
-
178
- Source: https://developer.apple.com/documentation/bundleresources/information_property_list
179
-
180
235
  ## Development
181
236
 
182
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.
183
238
 
184
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).
185
240
 
241
+ To see all available commands run `bundle exec rake -T` .
242
+
186
243
  ## Contributing
187
244
 
188
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.