@@ -15,6 +15,7 @@ const argv = require("minimist")(process.argv.slice(2))
15
15
******************************/
16
16
17
17
/**
18
+ * -b,--buckets Prints buckets overview and exits
18
19
* -v,--verbose Prints verbose console logs
19
20
* -f,--full Prints full name of buckets in summary
20
21
*/
@@ -43,12 +44,15 @@ const argv = require("minimist")(process.argv.slice(2))
43
44
* ie. `es: [1, 10],` would import the "Homepage" and "Learn" buckets for Spanish
44
45
* 2. Save file without committing*
45
46
*
46
- * Export/import translated content from Crowdin:
47
+ * Optionally: To view summary of buckets from CSV, run `yarn crowdin-import --buckets` or `yarn crowdin-import -b`
48
+ * Any items in USER_OVERRIDE will override the CSV import
49
+ *
50
+ * 3. Export translated content from Crowdin and import into ./.crowdin folder:
47
51
* 1. Export latest translated content from Crowdin and unzip
48
52
* 2. Copy languages folder from Crowdin export to ./.crowdin
49
53
* ie. ./.crowdin/{lang-codes}
50
54
*
51
- * Execute script:
55
+ * 4. Execute script:
52
56
* 1. Execute script by running `yarn crowdin-import`
53
57
* 2. If successful, copy `GATSBY_BUILD_LANGS={langs}` output and paste in
54
58
* your `.env`, then build site to test results.
@@ -58,7 +62,8 @@ const argv = require("minimist")(process.argv.slice(2))
58
62
59
63
type BucketsList = { [ key : string ] : Array < number > }
60
64
const USER_OVERRIDE : BucketsList = {
61
- // langCode: [bucket_number, bucket_number],
65
+ // FORMAT: lang_code: [bucket_number, bucket_number, ...],
66
+ // EXAMPLE: es: [1, 10, 12, 14],
62
67
}
63
68
64
69
/******************************
@@ -230,18 +235,21 @@ const highestBucketNumber: number = Object.values(bucketsToImport).reduce(
230
235
buckets [ buckets . length - 1 ] > prev ? buckets [ buckets . length - 1 ] : prev ,
231
236
0
232
237
)
238
+
239
+ /**
240
+ * If BUCKET_GENERATION_ONLY (-b, --buckets) flag is enabled, show overview
241
+ * of all langs and buckets to be imported. Also print a copy/paste ready
242
+ * object for USER_OVERRIDE, then exit the script early.
243
+ */
233
244
if ( BUCKET_GENERATION_ONLY ) {
234
245
const bucketsOverview = { }
235
246
Object . entries ( bucketsToImport ) . forEach ( ( [ langCode , buckets ] ) => {
236
247
bucketsOverview [ langCode ] = Array ( highestBucketNumber - 1 )
237
248
. fill ( 0 )
238
249
. map ( ( _ , i ) => ( buckets . includes ( i + 1 ) ? i + 1 : "" ) )
239
250
} )
240
- // Show buckets overview
241
251
console . table ( bucketsOverview )
242
- // Show buckets to import, set up for copy/paste to USER_OVERRIDE
243
252
console . log ( "const USER_OVERRIDE: BucketsList =" , bucketsToImport )
244
- // EXIT SCRIPT EARLY
245
253
process . exit ( 0 )
246
254
}
247
255
0 commit comments