ad_localize 3.6.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -1
- data/Gemfile.lock +34 -11
- data/README.md +148 -145
- data/ad_localize.gemspec +2 -0
- data/bin/console +1 -0
- data/exe/ad_localize +1 -1
- data/lib/ad_localize.rb +52 -11
- data/lib/ad_localize/ad_logger.rb +22 -9
- data/lib/ad_localize/cli.rb +10 -0
- data/lib/ad_localize/constant.rb +2 -21
- data/lib/ad_localize/entities/key.rb +74 -0
- data/lib/ad_localize/entities/locale_wording.rb +60 -0
- data/lib/ad_localize/entities/translation.rb +20 -0
- data/lib/ad_localize/entities/wording.rb +24 -0
- data/lib/ad_localize/interactors/execute_export_request.rb +43 -0
- data/lib/ad_localize/interactors/export_csv_files.rb +17 -0
- data/lib/ad_localize/interactors/export_g_spreadsheet.rb +55 -0
- data/lib/ad_localize/interactors/export_wording.rb +27 -0
- data/lib/ad_localize/interactors/merge_wordings.rb +43 -0
- data/lib/ad_localize/interactors/platforms/export_android_locale_wording.rb +39 -0
- data/lib/ad_localize/interactors/platforms/export_ios_locale_wording.rb +62 -0
- data/lib/ad_localize/interactors/platforms/export_json_locale_wording.rb +23 -0
- data/lib/ad_localize/interactors/platforms/export_platform_factory.rb +44 -0
- data/lib/ad_localize/interactors/platforms/export_properties_locale_wording.rb +29 -0
- data/lib/ad_localize/interactors/platforms/export_yaml_locale_wording.rb +23 -0
- data/lib/ad_localize/mappers/android_translation_mapper.rb +18 -0
- data/lib/ad_localize/mappers/csv_path_to_wording.rb +76 -0
- data/lib/ad_localize/mappers/ios_translation_mapper.rb +12 -0
- data/lib/ad_localize/mappers/locale_wording_to_hash.rb +25 -0
- data/lib/ad_localize/mappers/options_to_export_request.rb +28 -0
- data/lib/ad_localize/mappers/translation_group_mapper.rb +14 -0
- data/lib/ad_localize/mappers/translation_mapper.rb +30 -0
- data/lib/ad_localize/mappers/value_range_to_wording.rb +69 -0
- data/lib/ad_localize/option_handler.rb +30 -57
- data/lib/ad_localize/repositories/file_system_repository.rb +13 -0
- data/lib/ad_localize/repositories/g_sheets_repository.rb +44 -0
- data/lib/ad_localize/requests/export_request.rb +77 -0
- data/lib/ad_localize/requests/g_spreadsheet_options.rb +47 -0
- data/lib/ad_localize/requests/merge_policy.rb +28 -0
- data/lib/ad_localize/serializers/info_plist_serializer.rb +27 -0
- data/lib/ad_localize/serializers/json_serializer.rb +13 -0
- data/lib/ad_localize/serializers/localizable_strings_serializer.rb +27 -0
- data/lib/ad_localize/serializers/localizable_stringsdict_serializer.rb +35 -0
- data/lib/ad_localize/serializers/properties_serializer.rb +25 -0
- data/lib/ad_localize/serializers/strings_serializer.rb +33 -0
- data/lib/ad_localize/serializers/with_template.rb +19 -0
- data/lib/ad_localize/serializers/yaml_serializer.rb +13 -0
- data/lib/ad_localize/templates/android/strings.xml.erb +19 -0
- data/lib/ad_localize/templates/ios/InfoPlist.strings.erb +3 -0
- data/lib/ad_localize/templates/ios/Localizable.strings.erb +3 -0
- data/lib/ad_localize/templates/ios/Localizable.stringsdict.erb +41 -0
- data/lib/ad_localize/templates/properties/template.properties.erb +3 -0
- data/lib/ad_localize/version.rb +1 -1
- data/lib/ad_localize/view_models/translation_group_view_model.rb +15 -0
- data/lib/ad_localize/view_models/translation_view_model.rb +19 -0
- metadata +74 -11
- data/Makefile +0 -11
- data/lib/ad_localize/csv_file_manager.rb +0 -64
- data/lib/ad_localize/csv_parser.rb +0 -165
- data/lib/ad_localize/platform/android_formatter.rb +0 -70
- data/lib/ad_localize/platform/ios_formatter.rb +0 -143
- data/lib/ad_localize/platform/json_formatter.rb +0 -17
- data/lib/ad_localize/platform/platform_formatter.rb +0 -109
- data/lib/ad_localize/platform/yml_formatter.rb +0 -19
- data/lib/ad_localize/runner.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1581d41a8d5a3f41dc91cf69f4b8abfdf8c2121695cf116a46c738825818cbd9
|
4
|
+
data.tar.gz: 64af1cc80f9e9247514c334e13f6252e267283e3c38ade2d3111a4deb252164b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ebfdd0a7746acdaa06b713c6f129b04b7a81fb0441bf5975a47b415b892dd135b87c3e99e0610a98584adb2317f4d170a64230f932db3a3c0c3ecf8d00eabee
|
7
|
+
data.tar.gz: bd9a7140d68dc5f76c6c9e0dc19342180083205079d6d4e6022c0039176ae36f9e8c50441dec84bd5ea89f6596812c998be246163c3a9942e5fd9661379c3c30
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,46 @@ 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
|
+
|
7
47
|
## [3.6.0] - 2020-06-23
|
8
48
|
### Added
|
9
49
|
- add documentation for service account usage by [@sjcqs](https://github.com/sjcqs)
|
@@ -12,7 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
12
52
|
### Changed
|
13
53
|
|
14
54
|
### Fixed
|
15
|
-
|
55
|
+
|
16
56
|
## [3.5.0] - 2020-05-12
|
17
57
|
### Added
|
18
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)
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ad_localize (
|
4
|
+
ad_localize (4.0.0)
|
5
5
|
activesupport (>= 5.2, < 7.0)
|
6
6
|
colorize (~> 0.8)
|
7
|
+
google-api-client (~> 0.34)
|
7
8
|
googleauth (~> 0.12)
|
9
|
+
mime-types (~> 3.3)
|
8
10
|
nokogiri (~> 1.10)
|
9
11
|
|
10
12
|
GEM
|
11
13
|
remote: https://rubygems.org/
|
12
14
|
specs:
|
13
|
-
activesupport (6.0.3.
|
15
|
+
activesupport (6.0.3.3)
|
14
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
17
|
i18n (>= 0.7, < 2)
|
16
18
|
minitest (~> 5.1)
|
@@ -22,21 +24,36 @@ GEM
|
|
22
24
|
builder (3.2.4)
|
23
25
|
byebug (11.1.3)
|
24
26
|
colorize (0.8.1)
|
25
|
-
concurrent-ruby (1.1.
|
27
|
+
concurrent-ruby (1.1.7)
|
28
|
+
declarative (0.0.20)
|
29
|
+
declarative-option (0.1.0)
|
26
30
|
diffy (3.3.0)
|
27
31
|
faraday (1.0.1)
|
28
32
|
multipart-post (>= 1.2, < 3)
|
29
|
-
|
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)
|
30
42
|
faraday (>= 0.17.3, < 2.0)
|
31
43
|
jwt (>= 1.4, < 3.0)
|
32
44
|
memoist (~> 0.16)
|
33
45
|
multi_json (~> 1.11)
|
34
46
|
os (>= 0.9, < 2.0)
|
35
47
|
signet (~> 0.14)
|
36
|
-
|
48
|
+
httpclient (2.8.3)
|
49
|
+
i18n (1.8.5)
|
37
50
|
concurrent-ruby (~> 1.0)
|
38
|
-
jwt (2.2.
|
51
|
+
jwt (2.2.2)
|
39
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)
|
40
57
|
mini_portile2 (2.4.0)
|
41
58
|
minitest (5.14.0)
|
42
59
|
minitest-reporters (1.4.2)
|
@@ -44,13 +61,18 @@ GEM
|
|
44
61
|
builder
|
45
62
|
minitest (>= 5.0)
|
46
63
|
ruby-progressbar
|
47
|
-
multi_json (1.
|
64
|
+
multi_json (1.15.0)
|
48
65
|
multipart-post (2.1.1)
|
49
|
-
nokogiri (1.10.
|
66
|
+
nokogiri (1.10.10)
|
50
67
|
mini_portile2 (~> 2.4.0)
|
51
|
-
os (1.1.
|
52
|
-
public_suffix (4.0.
|
68
|
+
os (1.1.1)
|
69
|
+
public_suffix (4.0.6)
|
53
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)
|
54
76
|
ruby-progressbar (1.10.1)
|
55
77
|
signet (0.14.0)
|
56
78
|
addressable (~> 2.3)
|
@@ -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
|
-
|
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
|
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,51 +28,86 @@ $ gem install ad_localize
|
|
26
28
|
|
27
29
|
* Display help
|
28
30
|
```
|
29
|
-
$
|
31
|
+
$ ad_localize -h
|
30
32
|
```
|
31
33
|
|
32
|
-
* Export wording from a google spreadsheet,
|
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
|
-
$
|
36
|
+
$ ad_localize -k <your-spreadsheet-drive-key>
|
35
37
|
```
|
36
38
|
|
37
|
-
* Export wording from a google spreadsheet
|
39
|
+
* Export wording from a set of google spreadsheet tabs.
|
38
40
|
```
|
39
|
-
$
|
41
|
+
$ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
|
40
42
|
```
|
41
43
|
|
42
|
-
* Export wording from a
|
43
|
-
1. Create a GCloud Service Account:
|
44
|
-
- Go to [Google Cloud Console](https://console.cloud.google.com/)
|
45
|
-
- Either create a new project or use an existing one (when using Firebase, a GCloud project is created)
|
46
|
-
- Go to *IAM & Admin / Service Account* and create a new service account.
|
47
|
-
- Store the created `client-secret.json` (in a password manager for example)
|
48
|
-
2. Enable Google Drive API for the projet
|
49
|
-
- Go to *API / Library* and enable the **Drive API** there.
|
50
|
-
3. Add the service account to a spreadsheet.
|
51
|
-
- In *IAM & Admin / Service Account*, the service account's email is listed. Invite it to the spreadsheet to export.
|
44
|
+
* Export wording from all sheets in a google spreadsheet. It requires a [Google Cloud Service Account](#using-a-google-cloud-service-account).
|
52
45
|
```
|
53
|
-
$
|
54
|
-
$ 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
|
55
47
|
```
|
56
48
|
|
57
49
|
* Only generate wording files for the specified platforms
|
58
50
|
```
|
59
|
-
$
|
51
|
+
$ ad_localize -o ios
|
60
52
|
```
|
61
53
|
|
62
54
|
* Choose the path of the output directory
|
63
55
|
```
|
64
|
-
$
|
56
|
+
$ ad_localize -t <path-to-the-output-directory>
|
65
57
|
```
|
66
58
|
|
67
|
-
* Run in debug mode. In this mode, logs are more verbose
|
59
|
+
* Run in debug mode. In this mode, logs are more verbose
|
68
60
|
```
|
69
|
-
$
|
61
|
+
$ ad_localize -d
|
70
62
|
```
|
71
63
|
|
72
|
-
###
|
73
|
-
|
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
|
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
|
74
111
|
|
75
112
|
| key | fr | en |
|
76
113
|
| --- | --- | --- |
|
@@ -78,32 +115,96 @@ $ bundle exec ad_localize -d
|
|
78
115
|
| favorites | Mes favoris | My favorites |
|
79
116
|
| from_to | du %1$@ au %2$@ | from %1$@ to %2$@ |
|
80
117
|
|
81
|
-
- Any column after the `key` column will be considered as a locale column (except from the optional `comment columns)
|
82
|
-
- Keys should
|
83
|
-
- Format specifiers must be numeroted if there are more than one in a translation string (eg: "%1$@ %2$@'s report").
|
84
|
-
|
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"`).
|
85
121
|
|
86
|
-
|
122
|
+
### Comments
|
87
123
|
|
88
|
-
|
124
|
+
_Only for Android and iOS_
|
89
125
|
|
90
|
-
|
91
|
-
|
92
|
-
| player_time_live | Live | bypass-unused-error | Live | bypass-unused-error |
|
93
|
-
| 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` :
|
94
128
|
|
95
|
-
|
129
|
+
| key | en | comment en |
|
130
|
+
| --- | --- | --- |
|
131
|
+
| player_time_live | Live | bypass-unused-error |
|
132
|
+
| seconds | seconds | bypass-untranslated-error |
|
96
133
|
|
97
134
|
```
|
98
135
|
"player_time_live" = "Live"; // bypass-unused-error
|
99
136
|
"seconds" = "seconds"; // bypass-untranslated-error
|
100
137
|
```
|
101
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
|
+
|
102
200
|
## Output
|
103
201
|
|
104
|
-
The output folder name is `exports
|
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/`
|
105
206
|
|
106
|
-
|
207
|
+
Here an export tree example for all supported platforms in `fr` and `en`:
|
107
208
|
```
|
108
209
|
exports/
|
109
210
|
├── android
|
@@ -113,130 +214,32 @@ exports/
|
|
113
214
|
│ └── strings.xml
|
114
215
|
├── ios
|
115
216
|
│ ├── en.lproj
|
217
|
+
│ │ ├── InfoPlist.strings
|
116
218
|
│ │ ├── Localizable.strings
|
117
|
-
│ │
|
118
|
-
|
119
|
-
│
|
219
|
+
│ │ └── Localizable.stringsdict
|
220
|
+
│ └── fr.lproj
|
221
|
+
│ ├── InfoPlist.strings
|
120
222
|
│ ├── Localizable.strings
|
121
|
-
│
|
122
|
-
| └── InfoPlist.strings
|
223
|
+
│ └── Localizable.stringsdict
|
123
224
|
├── json
|
124
225
|
│ ├── en.json
|
125
226
|
│ └── fr.json
|
227
|
+
├── properties
|
228
|
+
│ ├── en.properties
|
229
|
+
│ └── fr.properties
|
126
230
|
└── yml
|
127
231
|
├── en.yml
|
128
232
|
└── fr.yml
|
129
233
|
```
|
130
234
|
|
131
|
-
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`.
|
132
|
-
|
133
|
-
## Plurals
|
134
|
-
|
135
|
-
Plurals are supported for iOS and Android.
|
136
|
-
|
137
|
-
Syntax for plural keys in the CSV file:
|
138
|
-
|
139
|
-
key##{few}
|
140
|
-
key##{one}
|
141
|
-
key##{other}
|
142
|
-
…
|
143
|
-
|
144
|
-
Sample of Android output in strings.xml
|
145
|
-
|
146
|
-
```xml
|
147
|
-
<resources>
|
148
|
-
<plurals name="cake">
|
149
|
-
<item quantity=["zero"|"one"]>gateau</item>
|
150
|
-
<item quantity="other">gateaux</item>
|
151
|
-
</plural>
|
152
|
-
</resources>
|
153
|
-
```
|
154
|
-
|
155
|
-
Sample of iOS output in .stringsdict
|
156
|
-
|
157
|
-
```xml
|
158
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
159
|
-
<plist>
|
160
|
-
<dict>
|
161
|
-
<key>traveller_type_child_title</key>
|
162
|
-
<dict>
|
163
|
-
<key>NSStringLocalizedFormatKey</key>
|
164
|
-
<string>%#@key@</string>
|
165
|
-
<key>key</key>
|
166
|
-
<dict>
|
167
|
-
<key>NSStringFormatSpecTypeKey</key>
|
168
|
-
<string>NSStringPluralRuleType</string>
|
169
|
-
<key>NSStringFormatValueTypeKey</key>
|
170
|
-
<string>d</string>
|
171
|
-
<key>zero</key>
|
172
|
-
<string/>
|
173
|
-
<key>one</key>
|
174
|
-
<string>1 enfant</string>
|
175
|
-
<key>two</key>
|
176
|
-
<string/>
|
177
|
-
<key>few</key>
|
178
|
-
<string/>
|
179
|
-
<key>many</key>
|
180
|
-
<string/>
|
181
|
-
<key>other</key>
|
182
|
-
<string>%d enfants</string>
|
183
|
-
</dict>
|
184
|
-
</dict>
|
185
|
-
</dict>
|
186
|
-
</plist>
|
187
|
-
```
|
188
|
-
|
189
|
-
## InfoPlist.strings
|
190
|
-
|
191
|
-
_Only for iOS._
|
192
|
-
|
193
|
-
Every key that matches the following formats will be added to the `InfoPlist.strings` file instead of `Localizable.strings`:
|
194
|
-
* `NS...UsageDescription`
|
195
|
-
* `CF...Name`
|
196
|
-
|
197
|
-
Source: https://developer.apple.com/documentation/bundleresources/information_property_list
|
198
|
-
|
199
|
-
## Adaptive strings
|
200
|
-
|
201
|
-
_Only for iOS._
|
202
|
-
|
203
|
-
Syntax for adaptive keys in the CSV file:
|
204
|
-
|
205
|
-
key##{20}
|
206
|
-
key##{25}
|
207
|
-
key##{50}
|
208
|
-
…
|
209
|
-
|
210
|
-
Sample of iOS output in .stringsdict
|
211
|
-
|
212
|
-
```xml
|
213
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
214
|
-
<plist>
|
215
|
-
<dict>
|
216
|
-
<key>start_countdown</key>
|
217
|
-
<dict>
|
218
|
-
<key>NSStringVariableWidthRuleType</key>
|
219
|
-
<dict>
|
220
|
-
<key>20</key>
|
221
|
-
<string>Start</string>
|
222
|
-
<key>25</key>
|
223
|
-
<string>Start countdown</string>
|
224
|
-
<key>50</key>
|
225
|
-
<string>Start countdown</string>
|
226
|
-
</dict>
|
227
|
-
</dict>
|
228
|
-
</dict>
|
229
|
-
</plist>
|
230
|
-
```
|
231
|
-
|
232
|
-
Source: https://developer.apple.com/documentation/foundation/nsstring/1413104-variantfittingpresentationwidth
|
233
|
-
|
234
235
|
## Development
|
235
236
|
|
236
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.
|
237
238
|
|
238
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).
|
239
240
|
|
241
|
+
To see all available commands run `bundle exec rake -T` .
|
242
|
+
|
240
243
|
## Contributing
|
241
244
|
|
242
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.
|