8
8
* License: GNU/GPLv2
9
9
* @see LICENSE.txt
10
10
*
11
- * This file: The loader (last modified: 2020.07.13 ).
11
+ * This file: The loader (last modified: 2020.07.16 ).
12
12
*/
13
13
14
14
namespace phpMussel \Core ;
@@ -567,29 +567,31 @@ public function loadL10N(string $Path = '')
567
567
/** Load client-specified L10N data if possible. */
568
568
if (!$ this ->Configuration ['core ' ]['lang_override ' ] || empty ($ _SERVER ['HTTP_ACCEPT_LANGUAGE ' ])) {
569
569
if (!($ this ->ClientL10N instanceof \Maikuolan \Common \L10N )) {
570
- $ this ->ClientL10N = &$ L10N ;
570
+ $ this ->ClientL10N = &$ this -> L10N ;
571
571
}
572
572
} else {
573
573
$ Accepted = preg_replace (['~^([^,]*).*$~ ' , '~[^-A-Za-z]~ ' ], ['\1 ' , '' ], $ _SERVER ['HTTP_ACCEPT_LANGUAGE ' ]);
574
574
$ Primary = '' ;
575
- if (
576
- $ this ->Configuration ['core ' ]['lang ' ] !== $ Accepted &&
577
- is_readable ( $ Path . $ Accepted . ' .yml ' )
578
- ) {
575
+ $ IsSameAs = false ;
576
+ if ( $ this ->Configuration ['core ' ]['lang ' ] === $ Accepted) {
577
+ $ IsSameAs = true ;
578
+ } elseif ( is_readable ( $ Path . $ Accepted . ' .yml ' ) ) {
579
579
$ Primary = $ this ->readFile ($ Path . $ Accepted . '.yml ' );
580
- }
581
- if (!$ Primary ) {
580
+ } else {
582
581
$ Accepted = strtolower (preg_replace ('~^([^-]*).*$~ ' , '\1 ' , $ Accepted ));
583
- if (
584
- $ this ->Configuration ['core ' ]['lang ' ] !== $ Accepted &&
585
- is_readable ($ Path . $ Accepted . '.yml ' )
586
- ) {
582
+ if ($ this ->Configuration ['core ' ]['lang ' ] === $ Accepted ) {
583
+ $ IsSameAs = true ;
584
+ } elseif (is_readable ($ Path . $ Accepted . '.yml ' )) {
587
585
$ Primary = $ this ->readFile ($ Path . $ Accepted . '.yml ' );
588
586
}
589
587
}
590
588
591
589
/** Process client-specified L10N data. */
592
- if ($ Primary ) {
590
+ if ($ IsSameAs ) {
591
+ if (!($ this ->ClientL10N instanceof \Maikuolan \Common \L10N )) {
592
+ $ this ->ClientL10N = &$ this ->L10N ;
593
+ }
594
+ } elseif ($ Primary ) {
593
595
$ Arr = [];
594
596
if (!$ this ->ClientL10NAccepted ) {
595
597
$ this ->ClientL10NAccepted = $ Accepted ;
@@ -603,7 +605,6 @@ public function loadL10N(string $Path = '')
603
605
$ this ->ClientL10N = new \Maikuolan \Common \L10N ($ Arr , $ this ->L10N );
604
606
}
605
607
} elseif (!($ this ->ClientL10N instanceof \Maikuolan \Common \L10N )) {
606
- $ this ->ClientL10NAccepted = $ Accepted ;
607
608
$ this ->ClientL10N = new \Maikuolan \Common \L10N ([], $ this ->L10N );
608
609
}
609
610
}
0 commit comments