locale-menu
Маршрут Части, которые сами по себе целый ответ, а не кусок ответа.
Переключатель языка: меню details из POST-форм с одним полем, так что выбор отправляется вашему приложению, а читатель остаётся на том же пути.
Каждый пример работает, но его ссылки никуда не ведут. HTML показывает разметку для копирования.
Двенадцать языков, текущий выделен.
Каждый язык — форма с одним полем, так что выбор языка — это POST, на который отвечает ваше приложение. Статический сайт может вместо этого использовать меню из обычных ссылок.
<footer rst-page-foot >
<details rst-dropdown rst-locale name ="rst-menus" >
<summary >
Язык
<span rst-caret aria-hidden ="true" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="m6 9 6 6 6-6" /></svg >
</span >
</summary >
<div rst-dropdown-menu >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="en" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="en" aria-current ="true" >English</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="ga" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="ga" >Gaeilge</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="zh-Hans" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="zh-Hans" >简体中文</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="es" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="es" >Español</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="hi" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="hi" >हिन्दी</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="pt-PT" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="pt-PT" >Português</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="bn" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="bn" >বাংলা</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="ru" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="ru" >Русский</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="ja" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="ja" >日本語</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="yue" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="yue" >廣東話</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="vi" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="vi" >Tiếng Việt</button >
</form >
<form method ="post" action ="/_locale" >
<input type ="hidden" name ="locale" value ="ar" >
<input type ="hidden" name ="return" value ="/" >
<button type ="submit" lang ="ar" >العربية</button >
</form >
</div >
</details >
</footer >
В приложении это вело бы на /_locale. Здесь его ссылки и формы никуда не ведут.