@@ -54,6 +54,11 @@ type Props = {
54
54
*/
55
55
defaultActive ?: boolean ;
56
56
57
+ /**
58
+ * The default locale id.
59
+ */
60
+ defaultLocaleId ?: React . Key ;
61
+
57
62
/**
58
63
* The initial selected locale id (uncontrolled).
59
64
*/
@@ -112,20 +117,20 @@ type Props = {
112
117
} ;
113
118
114
119
const TranslationLabel = ( {
115
- defaultLanguage ,
120
+ defaultLocaleId ,
116
121
locale,
117
122
messages,
118
123
translation,
119
124
} : {
120
- defaultLanguage : Item ;
125
+ defaultLocaleId : React . Key ;
121
126
messages : Messages ;
122
127
locale : Item ;
123
128
translation : Translation ;
124
129
} ) => {
125
130
let displayType : DisplayType = 'warning' ;
126
131
let label = messages . untranslated ;
127
132
128
- if ( locale . label === defaultLanguage ?. label ) {
133
+ if ( locale . id === defaultLocaleId ) {
129
134
displayType = 'info' ;
130
135
label = messages . default ;
131
136
} else if ( translation ) {
@@ -217,6 +222,7 @@ const ClayLanguagePicker = ({
217
222
active,
218
223
classNamesTrigger,
219
224
defaultActive = false ,
225
+ defaultLocaleId,
220
226
defaultSelectedLocaleId,
221
227
hideTriggerText,
222
228
id,
@@ -236,7 +242,6 @@ const ClayLanguagePicker = ({
236
242
spritemap,
237
243
translations = { } ,
238
244
} : Props ) => {
239
- const defaultLanguage = locales [ 0 ] ;
240
245
const hasTranslations = Object . keys ( translations ) . length ;
241
246
const selectedLocale = locales . find ( ( { id} ) => id === selectedLocaleId ) ;
242
247
@@ -283,7 +288,10 @@ const ClayLanguagePicker = ({
283
288
< ClayLayout . ContentCol containerElement = "span" >
284
289
< ClayLayout . ContentSection >
285
290
< TranslationLabel
286
- defaultLanguage = { defaultLanguage ! }
291
+ defaultLocaleId = {
292
+ defaultLocaleId ||
293
+ locales [ 0 ] ! . id
294
+ }
287
295
locale = { locale }
288
296
messages = { messages }
289
297
translation = {
0 commit comments