Dropdown Language Switcher
Provides a block with Drupal's Dropbutton element to switch site language, offering enhanced display options compared to the core Language Switcher Block.
dropdown_language
インストール
composer require 'drupal/dropdown_language:^4.1'
composer require 'drupal/dropdown_language:^3.1'
概要
Dropdown Languageモジュールは、単純なリンクの箇条書きリストではなく、Drupalの組み込みDropbutton UI要素を使用する拡張された言語切り替えブロックを提供します。これにより、多言語Webサイトに対して、よりコンパクトでユーザーフレンドリーなインターフェースを提供します。
このモジュールは、言語名、言語ID(コード)、ネイティブ言語名、またはブロックインスタンスごとの完全にカスタマイズ可能なラベルなど、柔軟なラベリングオプションを提供します。また、未翻訳コンテンツへのリンクをオプションでフィルタリングすることにより、言語切り替えリンクが実際に利用可能な翻訳のみを指すようにするSEO強化機能も含まれています。
このブロックは、言語が1つだけ設定されている場合は自動的に非表示になり、403/404エラーページではレンダリングされません。現在の言語はドロップダウンの上部に目立つように表示され、クリック不可のリンクとしてアクティブとしてマークされます。
Features
- コンパクトな表示のためにDrupalのdropbutton要素を使用する言語切り替えブロック
- 複数の表示オプション:言語名、言語ID(コード)、ネイティブ名、またはカスタムラベル
- 視覚的なグループ化のための「Switch Language」タイトル付きオプションのfieldsetラッパー
- SEO強化:未翻訳コンテンツをフィルタリングして利用可能な翻訳へのリンクのみを表示
- 翻訳が1つだけ利用可能な場合でもブロックを表示し続けるオプション
- 403/404エラーページでの自動ブロック非表示
- 現在の言語がアクティブスタイリングとクリック不可で上部に表示
- 複数の言語タイプをサポート:インターフェース言語とコンテンツ言語
- カスタムラベルモードが選択されている場合のブロックインスタンスごとのカスタムラベル
- Drupalの言語ネゴシエーションシステムと統合
Use Cases
Basic Multilingual Website
For a website with multiple languages where visitors need to switch between language versions. Place the Dropdown Language block in the header region and configure it to show language names. The compact dropdown format saves space while providing clear language selection.
SEO-Optimized Language Switcher
For websites where SEO is important and you want to avoid showing language links for untranslated content. Enable the 'Filter Untranslated' option to automatically hide language options that don't have actual translations, preventing search engines from indexing empty or fallback content pages.
Custom Language Labels for Branding
For websites that need specific language labels (e.g., showing flags with text, abbreviations, or custom terminology). Select 'Custom Labels' in global settings, then configure each block instance with the desired labels for each language.
Compact Language Code Display
For designs where space is limited and a compact representation is preferred. Select 'Language ID' display mode to show two-letter language codes (EN, DE, FR) instead of full language names.
Separate Interface and Content Language Switching
For advanced multilingual setups where interface language (menu, UI elements) and content language can be different. Place separate Dropdown Language blocks for each language type, allowing users to independently control interface and content languages.
Tips
- Place the block in a highly visible region like the header for easy access
- Use Native Name display for international audiences as visitors can identify their language more easily
- When using Custom Labels mode, create separate block instances per language and use Language visibility conditions to show the appropriate labels for each language
- The current language is automatically placed at the top of the dropdown and styled with an 'active-language' CSS class for custom styling
- Consider enabling the fieldset wrapper ('Switch Language' Decor) to make the language switcher more prominent and accessible
Technical Details
Admin Pages 1
/admin/config/regional/dropdown-language-switcher
Global configuration settings for all Dropdown Language Switcher blocks. Controls how language labels are displayed and visual presentation options.
Hooks 1
hook_help
Provides help text for the module on the admin help page
Troubleshooting 5
Ensure at least two languages are configured at Administration > Configuration > Regional and Language > Languages. The block automatically hides when only one language is available unless 'Keep block visible' option is enabled.
Navigate to Administration > Configuration > Regional and Language > Languages, click 'Edit' on your default language (e.g., English), check 'Enable interface translation to English', and save. Then use User interface translation to translate the string.
This is expected behavior - the module intentionally does not render the block on error pages (403 Forbidden and 404 Not Found) to avoid confusion and broken links.
Ensure 'Custom Labels' is selected in the global settings at /admin/config/regional/dropdown-language-switcher. Then edit each block instance to configure the custom labels for each language.
Enable 'Remove links if no translation is detected' in the global settings. Note this only works with Entity-based content (nodes, taxonomy terms, etc.) and requires proper translation configuration.
Security Notes 2
- The module requires 'administer site configuration' permission to access the settings page
- Translation access is checked before showing language links when filter_untranslated is enabled - users without view access to a translation won't see that language option