@@ -72,6 +72,8 @@ const locales = {
7272  th : {  L : 'DD/MM/YYYY'  } , 
7373  // Turkish 
7474  tr : {  dow : 2 ,  L : 'DD.MM.YYYY'  } , 
75+   // Ukrainian 
76+   uk : {  dow : 2 ,  L : 'DD.MM.YYYY'  } , 
7577} ; 
7678locales . en  =  locales [ 'en-US' ] ; 
7779locales . zh  =  locales [ 'zh-CN' ] ; 
@@ -92,18 +94,35 @@ const getDayNames = (locale, length) => {
9294  return  getWeekdayDates ( {  utc : true  } ) . map ( d  =>  dtf . format ( d ) ) ; 
9395} ; 
9496
95- export  default  ( locale ,  defaults )  =>  { 
96-   locale  =  locale  ||  new  Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale ; 
97-   const  searchLocales  =  [ locale ,  locale . substring ( 0 ,  2 ) ,  'en-US' ] ; 
98-   const  matchKey  =  searchLocales . find ( l  =>  locales [ l ] ) ; 
99-   const  matchValue  =  locales [ matchKey ] ; 
100-   defaults . locale  =  matchKey ; 
101-   defaults . firstDayOfWeek  =  matchValue . dow  ||  1 ; 
102-   defaults . dayNames  =  getDayNames ( matchKey ,  'long' ) ; 
103-   defaults . dayNamesShort  =  getDayNames ( matchKey ,  'short' ) ; 
104-   defaults . dayNamesShorter  =  defaults . dayNamesShort . map ( s  =>  s . substring ( 0 ,  2 ) ) ; 
105-   defaults . dayNamesNarrow  =  getDayNames ( matchKey ,  'narrow' ) ; 
106-   defaults . monthNames  =  getMonthNames ( matchKey ,  'long' ) ; 
107-   defaults . monthNamesShort  =  getMonthNames ( matchKey ,  'short' ) ; 
108-   defaults . masks  =  {  L : matchValue . L  } ; 
97+ export  default  locale  =>  { 
98+   const  detectedLocale  =  new  Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale ; 
99+   const  searchLocales  =  [ 
100+     locale , 
101+     locale  &&  locale . substring ( 0 ,  2 ) , 
102+     detectedLocale , 
103+   ] ; 
104+   const  resolvedLocale  = 
105+     searchLocales . find ( l  =>  locales [ l ] )  ||  locale  ||  detectedLocale ; 
106+   const  localeExtra  =  { 
107+     dow : 1 , 
108+     L : 'DD/MM/YYYY' , 
109+     ...locales [ resolvedLocale ] , 
110+   } ; 
111+   const  dayNames  =  getDayNames ( resolvedLocale ,  'long' ) ; 
112+   const  dayNamesShort  =  getDayNames ( resolvedLocale ,  'short' ) ; 
113+   const  dayNamesShorter  =  dayNamesShort . map ( s  =>  s . substring ( 0 ,  2 ) ) ; 
114+   const  dayNamesNarrow  =  getDayNames ( resolvedLocale ,  'narrow' ) ; 
115+   const  monthNames  =  getMonthNames ( resolvedLocale ,  'long' ) ; 
116+   const  monthNamesShort  =  getMonthNames ( resolvedLocale ,  'short' ) ; 
117+   return  { 
118+     locale : resolvedLocale , 
119+     firstDayOfWeek : localeExtra . dow , 
120+     masks : {  L : localeExtra . L  } , 
121+     dayNames, 
122+     dayNamesShort, 
123+     dayNamesShorter, 
124+     dayNamesNarrow, 
125+     monthNames, 
126+     monthNamesShort, 
127+   } ; 
109128} ; 
0 commit comments