Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create the translations drop down? #2257

Closed
harryhanYuhao opened this issue Aug 1, 2024 · 2 comments
Closed

How to create the translations drop down? #2257

harryhanYuhao opened this issue Aug 1, 2024 · 2 comments

Comments

@harryhanYuhao
Copy link

I am also writing a book with mdbook.
I wonder how to you guys implement the globe sign on the upper right and the drop down menu for choosing languages?

I know the book uses mdbook-118n for internationalization, but I could not find anything relevant on the dropdown menu.

Thanks in advance.

@djmitche
Copy link
Collaborator

djmitche commented Aug 1, 2024

It's in theme/index.hbs:

<div class="right-buttons">
<button id="language-toggle" class="icon-button" type="button"
title="Change language" aria-label="Change language"
aria-haspopup="true" aria-expanded="false"
aria-controls="language-list">
<i class="fa fa-globe"></i>
</button>
<ul id="language-list" class="theme-popup" aria-label="Languages" role="menu">
<li role="none"><button role="menuitem" class="theme">
<a id="en">English</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="pt-BR">Brazilian Portuguese (Português do Brasil)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="zh-CN">Chinese Simplified (汉语)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="zh-TW">Chinese Traditional (漢語)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="ja">Japanese (日本語)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="ko">Korean (한국어)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="es">Spanish (Español)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="uk">Ukrainian (українська)</a>
</button></li>
</ul>

@mgeisler
Copy link
Collaborator

mgeisler commented Sep 7, 2024

Hi @harryhanYuhao, this is a definitely a pain point! We have google/mdbook-i18n-helpers#12 for figuring out how to package a language selector somehow. If you have any ideas, then I suggest adding them there 😄

@mgeisler mgeisler closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants