Skip to content

Commit 0f68e26

Browse files
committed
Polishing
1 parent a86ced9 commit 0f68e26

File tree

3 files changed

+105
-76
lines changed

3 files changed

+105
-76
lines changed

README.md

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ The installation process is automated by command-line scripts. Both scripts for
3030

3131
```shell
3232
# macOs / Linux / Windows (WSL)
33-
curl -s https://get.simplelocalize.io/2.6/install | bash
33+
curl -s https://get.simplelocalize.io/2.7/install | bash
3434

3535
# Windows (PowerShell)
36-
. { iwr -useb https://get.simplelocalize.io/2.6/install-windows } | iex;
36+
. { iwr -useb https://get.simplelocalize.io/2.7/install-windows } | iex;
3737
```
3838
3939
To change or update the CLI version, run the installation script with the desired version number in the URL, e.g.:
@@ -44,8 +44,8 @@ See [releases](https://github.com/simplelocalize/simplelocalize-cli/releases) fo
4444
4545
## Usage
4646
47-
The command-line tool offers several commands to execute.
48-
All of them requires `--apiKey YOUR_API_KEY` parameter that is unique for each project.
47+
The command-line tool offers several commands to execute. All of them requires Project API Key that is unique for each project.
48+
You can set `apiKey` in simplelocalize.yml configuration file, pass it as parameter with `--apiKey` or set it by environment variable `SIMPLELOCALIZE_API_KEY`.
4949
5050
```shell
5151
simplelocalize [command] ...parameters
@@ -56,17 +56,12 @@ Available commands:
5656
- `status` - gets translation project details
5757
- `upload` - uploads translation files or translation keys
5858
- `download` - downloads translation files
59-
- `sync` - uploads translation files and downloads translation files
60-
- `auto-translate` - starts [auto-translation](https://simplelocalize.io/auto-translation) jobs
61-
- `pull` - downloads translation files from [Translation Hosting](https://simplelocalize.io/translation-hosting)
62-
- `publish` - publishes translations to [Translation Hosting](https://simplelocalize.io/translation-hosting)
63-
- `purge` - removes all translation, translation keys and languages from [Translation Editor](https://simplelocalize.io/translation-editor)
59+
- `auto-translate` - starts [auto-translation](https://simplelocalize.io/auto-translation/) jobs
60+
- `pull` - downloads translation files from [Translation Hosting](https://simplelocalize.io/translation-hosting/)
61+
- `publish` - publishes translations to [Translation Hosting](https://simplelocalize.io/translation-hosting/)
62+
- `purge` - removes all translation, translation keys and languages from the project
6463
- `extract` - finds and extracts translation keys in your project files
6564
66-
67-
Use `--help` parameter to get more information about the command and its parameters
68-
or [check documentation](https://simplelocalize.io/docs/cli/get-started/).
69-
7065
## Create configuration file
7166
7267
Command creates a sample configuration file in the current directory.
@@ -79,7 +74,9 @@ simplelocalize init
7974
8075
## Upload translations
8176
82-
Command uploads translation files from given `<UPLOAD_PATH_PATTERN>` to [Translation Editor](https://simplelocalize.io/translation-editor/), e.g.: `./src/translations/messages.json`.
77+
Upload command takes your local files and uploads them to SimpleLocalize. You can specify a path to the file or use placeholders to upload many files at once.
78+
A good practise is to **upload only source translations** instead of uploading all translations on each run. You can use `{lang}` placeholder to specify language or locale and `{ns}` placeholder to specify namespace,
79+
e.g.: `./src/translations/{lang}/{ns}.json`.
8380
8481
```shell
8582
simplelocalize upload
@@ -88,9 +85,6 @@ simplelocalize upload
8885
--uploadFormat <UPLOAD_FORMAT>
8986
```
9087
91-
You can use `{lang}` placeholder to specify language or locale and `{ns}` placeholder to specify namespace,
92-
e.g.: `./src/translations/{lang}/{ns}.json`.
93-
9488
Upload format is a format of the file(s) with translations. [See available upload formats](https://simplelocalize.io/docs/general/file-formats/)
9589
9690
**Additional parameters:**
@@ -101,7 +95,7 @@ E.g.: `--uploadOptions TRIM_LEADING_TRAILING_SPACES`. To pass multiple options,
10195
10296
Learn more about [upload translations command](https://simplelocalize.io/docs/cli/upload-translations/).
10397
104-
### Example: One file with translations
98+
### Example: One file with multiple languages
10599
106100
```bash
107101
.
@@ -113,12 +107,38 @@ Command:
113107
```
114108
simplelocalize upload
115109
--apiKey <PROJECT_API_KEY>
116-
--uploadPath /locales/messages.json
110+
--uploadPath ./locales/messages.json
117111
--uploadFormat multi-language-json
118112
```
119113
114+
### Example: One file per language
115+
116+
In this example we upload only source translations from `./en/messages.json` and uses `--uploadLanguageKey en-GB` to specify language key for the uploaded file for the Translation Editor.
117+
It's a recommended way to upload source translations.
118+
119+
```bash
120+
.
121+
├── ca
122+
│   └── messages.json
123+
├── en
124+
│   └── messages.json
125+
└── es
126+
└── messages.json
127+
```
128+
129+
Command:
130+
```
131+
simplelocalize upload
132+
--apiKey <PROJECT_API_KEY>
133+
--uploadPath ./en/index.json
134+
--uploadLanguageKey en-GB
135+
--uploadFormat single-language-json
136+
```
120137
121-
### Example: Single file in multiple language directories
138+
### Example: One file per language using placeholders
139+
140+
In this example we use `{lang}` placeholder to upload **many files** at once and specify language key for each file.
141+
It's not a recommended way to upload source translations, as it uploads more files than necessary.
122142
123143
```bash
124144
.
@@ -138,17 +158,19 @@ simplelocalize upload
138158
--uploadFormat single-language-json
139159
```
140160
141-
### Example: Multiple files in multiple language directories
161+
### Example: One file per language and namespace
162+
163+
In this example we use `{ns}` placeholder to upload **many files** at once for the English language. We used `--uploadLanguageKey en-GB` to specify language key for the uploaded file for the Translation Editor.
142164
143165
```bash
144166
.
145-
├── ca
167+
├── italian
146168
│   ├── common.json
147169
│   └── home.json
148-
├── en
170+
├── english
149171
│   ├── common.json
150172
│   └── home.json
151-
└── es
173+
└── spanish
152174
├── common.json
153175
└── home.json
154176
```
@@ -157,15 +179,15 @@ Command:
157179
```
158180
simplelocalize upload
159181
--apiKey <PROJECT_API_KEY>
160-
--uploadPath /{lang}/{ns}.json
182+
--uploadPath /english/{ns}.json
183+
--uploadLanguageKey en-GB
161184
--uploadFormat single-language-json
162185
```
163186
164187
165188
## Download translations
166189
167-
Command downloads translation files from the [Translation Editor](https://simplelocalize.io/translation-editor/) to the given `<DOWNLOAD_PATH_PATTERN>`,
168-
e.g.: `./src/translations/messages.json`.
190+
Download works similarly to the upload command, but this time it exports translation files from the Translation Editor to your local files.
169191
170192
```shell
171193
simplelocalize download
@@ -174,20 +196,30 @@ simplelocalize download
174196
--downloadFormat <DOWNLOAD_FORMAT>
175197
```
176198
177-
You can use `{lang}` placeholder to specify language or locale and `{ns}` placeholder to specify namespace,
178-
e.g.: `./src/translations/{lang}/{ns}.json`.
199+
Download format is a format of the file(s) with translations. [See available upload formats](https://simplelocalize.io/docs/general/file-formats/)
200+
201+
### Example
179202
180-
Download format is a format of the file(s) with translations. [See available download formats](https://simplelocalize.io/docs/general/file-formats/)
203+
Same as before you can use `{lang}` and `{ns}` placeholders to download many files at once and specify language keys that should be downloaded, eg.:
204+
205+
```shell
206+
simplelocalize download
207+
--apiKey <PROJECT_API_KEY>
208+
--downloadPath ./src/{ns}/messages_{lang}.json
209+
--downloadFormat single-language-json
210+
--downloadLanguageKey en,de,fr
211+
```
181212
182213
**Additional parameters:**
214+
- `--downloadLanguageKey` allows you to download translation for specified languages. Eg.: `--downloadLanguageKey en,de,fr`.
183215
- `--downloadOptions` allows you to pass [additional options](https://simplelocalize.io/docs/general/options/) to the download command. Eg.: `--downloadOptions WRITE_NESTED`.
184216
- `--downloadSort` allows you to sort translations in the downloaded file. Eg.: `--downloadSort NEWEST_KEYS_FIRST`. Available options: `NEWEST_KEYS_FIRST`, `NEWEST_KEYS_LAST`, `NAMESPACES`, `IMPORT_ORDER`.
185217
186218
Learn more about [download translations command](https://simplelocalize.io/docs/cli/download-translations/).
187219
188220
## Auto-translate strings
189221
190-
Auto-translate command starts [auto-translation](https://simplelocalize.io/auto-translation) jobs for all languages in the project or for languages specified in `--languageKeys` parameter.
222+
Auto-translate command starts auto-translation tasks for all languages in the project or for languages specified in `--languageKeys` parameter.
191223
Auto-translation configuration is taken from the last auto-translation job in the project for the given language.
192224
193225
```properties
@@ -237,24 +269,6 @@ Command gets project details and prints them to the console.
237269
simplelocalize status --apiKey <PROJECT_API_KEY>
238270
```
239271
240-
## Sync translations
241-
242-
Sync command combines upload and download command executions.
243-
244-
```properties
245-
simplelocalize sync
246-
--apiKey <PROJECT_API_KEY>
247-
--downloadPath <DOWNLOAD_PATH>
248-
--downloadFormat <DOWNLOAD_FORMAT>
249-
--downloadOptions <DOWNLOAD_OPTIONS>
250-
--uploadPath <UPLOAD_PATH>
251-
--uploadFormat <UPLOAD_FORMAT>
252-
--uploadOptions <UPLOAD_OPTIONS>
253-
```
254-
255-
`--downloadOptions` and `--uploadOptions` parameters are optional.
256-
257-
258272
## Purge translations
259273
260274
Command removes all translations, translation keys and languages from [Translation Editor](https://simplelocalize.io/translation-editor).
@@ -307,15 +321,17 @@ Filename: `simplelocalize.yml`
307321
apiKey: API_KEY
308322
309323
# Properties used by 'upload' command
310-
uploadPath: ./src/{lang}/{ns}.json
324+
uploadPath: ./source-translations/messages_en.json
325+
uploadLanguageKey: en-GB
311326
uploadFormat: single-language-json
312327
uploadOptions:
313328
# by default, the 'upload' command only adds new keys and fills empty translations,
314329
# add this option to overwrite existing translations with values from the uploaded file
315330
- REPLACE_TRANSLATION_IF_FOUND
316331
317332
# Properties used by 'download' command
318-
downloadPath: ./src/{ns}/messages_{lang}.json
333+
downloadPath: ./output-translations/messages_{lang}.json
334+
downloadLanguageKey: ['de-DE', 'fr-FR', 'pl-PL']
319335
downloadFormat: single-language-json
320336
downloadOptions:
321337
- WRITE_NESTED
@@ -329,8 +345,7 @@ ignoreKeys:
329345
330346
# Properties used by 'pull' and 'publish' command
331347
pullPath: ./src/hosting/
332-
environment: '_production' # or '_latest', or 'my_custom'
333-
348+
environment: '_production' # or '_latest', or 'my_custom'
334349
```
335350
336351
## Proxy support
@@ -358,4 +373,3 @@ Please refer to the [official SimpleLocalize documentation](https://simplelocali
358373
## License
359374
360375
See [LICENSE](/LICENSE) for more details.
361-

src/main/java/io/simplelocalize/cli/command/DownloadCommand.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public void invoke() throws IOException, InterruptedException
3535
final String downloadPath = configuration.getDownloadPath();
3636
ConfigurationValidatorUtil.validateIsNotEmptyOrNull(downloadPath, "downloadPath");
3737

38-
log.info("Download path: {}", downloadPath);
38+
log.info("Path: {}", downloadPath);
3939
log.info("File format: {}", downloadFormat);
4040

4141
final List<String> languageKeys = configuration.getDownloadLanguageKeys();
42-
log.info("Language key(s): {}", languageKeys);
42+
if (!languageKeys.isEmpty())
43+
{
44+
log.info("Language(s): {}", languageKeys);
45+
}
4346

4447
final String sort = configuration.getDownloadSort();
4548
if (StringUtils.isNotEmpty(sort))
@@ -70,7 +73,10 @@ public void invoke() throws IOException, InterruptedException
7073
downloadOptions.add("SPLIT_BY_LANGUAGES");
7174
}
7275

73-
log.info("Options: {}", downloadOptions);
76+
if (!downloadOptions.isEmpty())
77+
{
78+
log.info("Options: {}", downloadOptions);
79+
}
7480

7581
final ExportRequest exportRequest = ExportRequest.builder()
7682
.withFormat(downloadFormat)
@@ -81,13 +87,11 @@ public void invoke() throws IOException, InterruptedException
8187
.withSort(sort)
8288
.build();
8389
final List<DownloadableFile> downloadableFiles = client.exportFiles(exportRequest);
84-
int downloadedFilesCounter = 0;
8590
for (DownloadableFile downloadableFile : downloadableFiles)
8691
{
8792
client.downloadFile(downloadableFile, downloadPath);
88-
downloadedFilesCounter++;
8993
}
90-
log.info("Downloaded {} file(s) from SimpleLocalize", downloadedFilesCounter);
94+
log.info("Successfully downloaded all files");
9195
}
9296

9397
}

0 commit comments

Comments
 (0)