@@ -119,19 +119,19 @@ public function ready() {
119119 $ this ->fluencyConfig = (new FluencyConfig ())->getConfigData ();
120120 $ this ->translationCache = new TranslationCache ();
121121 $ this ->engineLanguagesCache = new EngineLanguagesCache ();
122+ $ this ->initializeTranslationEngine ();
122123
123- if (!$ this ->moduleShouldInit ()) {
124+ if (!$ this ->moduleShouldInitInAdmin ()) {
124125 return false ;
125126 }
126127
127- $ this ->initializeTranslationEngine ();
128- $ this ->insertPageAssets ();
128+ $ this ->insertAdminAssets ();
129129 }
130130
131131 /**
132132 * Determine if module should initialize
133133 */
134- private function moduleShouldInit (): bool {
134+ private function moduleShouldInitInAdmin (): bool {
135135 return $ this ->page ->name !== 'login ' && $ this ->userIsAuthorized ();
136136 }
137137
@@ -159,7 +159,7 @@ private function userIsAuthorized(): bool {
159159 /**
160160 * Inserts required assets into admin pages on load.
161161 */
162- private function insertPageAssets (): void {
162+ private function insertAdminAssets (): void {
163163 if ($ this ->page ->rootParent ->id !== 2 ) {
164164 return ;
165165 }
@@ -286,7 +286,9 @@ public function getConfiguredLanguages(): AllConfiguredLanguagesData {
286286 $ engineInfo = $ this ->translationEngineInfo ;
287287
288288 if (!$ engineInfo ?->configId) {
289- return [];
289+ return AllConfiguredLanguagesData::fromArray ([
290+ 'languages ' => []
291+ ]);
290292 }
291293
292294 if (!is_null ($ this ->configuredLanguages )) {
@@ -308,11 +310,7 @@ public function getConfiguredLanguages(): AllConfiguredLanguagesData {
308310
309311 $ processWireLanguages = array_values ($ this ->languages ->getIterator ()->getArray ());
310312
311- $ languages = array_reduce (
312- $ processWireLanguages ,
313- $ createConfiguredLanguage ,
314- []
315- );
313+ $ languages = array_reduce ($ processWireLanguages , $ createConfiguredLanguage , []);
316314
317315 // Create an array of Fluency configured language object from an array of ProcessWire languages
318316 return $ this ->configuredLanguages = AllConfiguredLanguagesData::fromArray ([
@@ -411,7 +409,7 @@ public function getUnconfiguredLanguages(): array {
411409 *
412410 * #pw-group-Fluency-Module-Configuration-Data
413411 *
414- * @return array Array with all data needed by client UI scripts.
412+ * @return stdClass All data needed by client UI scripts.
415413 */
416414 public function getClientData (): stdClass {
417415 return (object ) [
@@ -587,6 +585,7 @@ public function renderLanguageLinks(
587585 string $ languageSource = 'fluency ' ,
588586 ): string {
589587 $ languages = $ this ->getLanguagesForMarkup ($ languageSource );
588+ $ divider && $ divider = Markup::li (content: $ divider , classes: 'divider ' );
590589
591590 $ items = array_reduce ($ languages , function ($ tags , $ language ) use ($ activeClass , $ divider ) {
592591 $ tags [] = Markup::li (
@@ -597,7 +596,7 @@ classes: $language->isCurrentLanguage ? $activeClass : null,
597596 )
598597 );
599598
600- $ divider && $ tags [] = Markup:: li (content: $ divider, classes: ' divider ' ) ;
599+ $ divider && $ tags [] = $ divider ;
601600
602601 return $ tags ;
603602 }, []);
0 commit comments