Commit 7260b69 1 parent c997462 commit 7260b69 Copy full SHA for 7260b69
File tree 2 files changed +8
-0
lines changed
2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const cli = meow(
15
15
-f, --format json | yaml [default: json]
16
16
-d, --default-locale default locale
17
17
--flat json [default: true] | yaml [default: false]
18
+ --sort-when-not-flat keys are sorted even when flat option is false [default: false]
18
19
19
20
Example
20
21
$ extract-messages --locales=ja,en --output app/translations 'app/**/*.js'
@@ -25,6 +26,9 @@ const cli = meow(
25
26
flat : {
26
27
type : 'boolean'
27
28
} ,
29
+ 'sort-when-not-flat' : {
30
+ type : 'boolean'
31
+ } ,
28
32
output : {
29
33
type : 'string' ,
30
34
alias : 'o'
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ type Opts = {
61
61
defaultLocale : string
62
62
format ?: string
63
63
flat ?: boolean
64
+ sortWhenNotFlat ?: boolean
64
65
[ key : string ] : unknown
65
66
}
66
67
@@ -72,6 +73,7 @@ const extractMessage = async (
72
73
{
73
74
format = 'json' ,
74
75
flat = isJson ( format ) ,
76
+ sortWhenNotFlat = false ,
75
77
defaultLocale = 'en' ,
76
78
...opts
77
79
} : Opts = {
@@ -121,6 +123,8 @@ const extractMessage = async (
121
123
122
124
const fomattedLocaleMap : object = flat
123
125
? sortKeys ( localeMap , { deep : true } )
126
+ : sortWhenNotFlat
127
+ ? sortKeys ( unflatten ( localeMap , { object : true } ) , { deep : true } )
124
128
: unflatten ( sortKeys ( localeMap ) , { object : true } )
125
129
126
130
const fn = isJson ( format ) ? writeJson : writeYaml
You can’t perform that action at this time.
0 commit comments