Don't show language chooser if only one option is available
authorMarcel Werk <burntime@woltlab.com>
Wed, 2 Aug 2023 13:17:53 +0000 (15:17 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 2 Aug 2023 13:17:53 +0000 (15:17 +0200)
com.woltlab.wcf/templates/messageFormMultilingualism.tpl

index 6eac1751b2e46aa5840a03eb6dea582c6354bb85..dfcd5665212551d342fec94d23b43884a5730de8 100644 (file)
@@ -1,29 +1,35 @@
 {if $availableContentLanguages|count}
-       <dl{if $errorField == 'languageID'} class="formError"{/if}>
-               <dt>{lang}wcf.user.language{/lang}</dt>
-               <dd id="languageIDContainer">
-                       <noscript>
-                               <select name="languageID" id="languageID">
-                                       {foreach from=$availableContentLanguages item=contentLanguage}
-                                               <option value="{$contentLanguage->languageID}">{$contentLanguage}</option>
-                                       {/foreach}
-                               </select>
-                       </noscript>
-               </dd>
-       </dl>
-       
-       <script data-relocate="true">
-               require(['WoltLabSuite/Core/Language/Chooser'], function(LanguageChooser) {
-                       var languages = {
-                               {implode from=$availableContentLanguages item=_language}
-                                       '{@$_language->languageID}': {
-                                               iconPath: '{@$_language->getIconPath()|encodeJS}',
-                                               languageName: '{@$_language|encodeJS}'
-                                       }
-                               {/implode}
-                       };
-                       
-                       LanguageChooser.init('languageIDContainer', 'languageID', {$languageID}, languages)
-               });
-       </script>
+       {if $availableContentLanguages|count == 1}
+               {foreach from=$availableContentLanguages item=contentLanguage}
+                       <input type="hidden" name="languageID" value="{$contentLanguage->languageID}">
+               {/foreach}
+       {else}
+               <dl{if $errorField == 'languageID'} class="formError"{/if}>
+                       <dt>{lang}wcf.user.language{/lang}</dt>
+                       <dd id="languageIDContainer">
+                               <noscript>
+                                       <select name="languageID" id="languageID">
+                                               {foreach from=$availableContentLanguages item=contentLanguage}
+                                                       <option value="{$contentLanguage->languageID}">{$contentLanguage}</option>
+                                               {/foreach}
+                                       </select>
+                               </noscript>
+                       </dd>
+               </dl>
+               
+               <script data-relocate="true">
+                       require(['WoltLabSuite/Core/Language/Chooser'], function(LanguageChooser) {
+                               var languages = {
+                                       {implode from=$availableContentLanguages item=_language}
+                                               '{@$_language->languageID}': {
+                                                       iconPath: '{@$_language->getIconPath()|encodeJS}',
+                                                       languageName: '{@$_language|encodeJS}'
+                                               }
+                                       {/implode}
+                               };
+                               
+                               LanguageChooser.init('languageIDContainer', 'languageID', {$languageID}, languages)
+                       });
+               </script>
+       {/if}
 {/if}