Language Flags Module for Magento 2
One switcher for multiple language scenarios
Kowal_LanguageFlags solves the problem of a poorly readable language switcher in Magento 2. Instead of the standard list of store view codes, the customer sees an intuitive switcher with flags, language names, and the ability to switch not only between store views, but also between websites and external stores.
This solution is especially useful where:
- one store supports several language versions;
- different markets operate as separate websites;
- part of the traffic should go to another Magento instance;
- one consistent switcher is needed for different types of target addresses.
What the module provides
- flags for store views;
- flags for other websites in the same Magento instance;
- flags for any URLs, for example to a separate Magento store;
- custom labels and shortened language codes;
- two display variants:
dropdownandinline; - support for the native Magento switcher and the widget.
Business benefits
- faster recognition of the language version by the customer;
- fewer errors when selecting a market or language;
- a more professional presentation of a multilingual store;
- the ability to conveniently connect multiple storefronts in one navigation point;
- a shorter implementation path than building a dedicated component from scratch.
Technical benefits
- configuration from the admin panel;
- compatibility with the native Magento mechanism for store view switching;
- one configuration for the native switcher and the widget;
- a default set of ready-made SVG flags copied to
pub/media/language_flags/during installation; - no need to build a separate data table at the start;
- the option to deploy via Composer.
Ready-made flag set
The module includes a set of ready-made SVG icons in 24x18 format, which can be automatically copied to pub/media/language_flags/ during bin/magento setup:upgrade.
Available flags:
atAustriabeBelgiumbgBulgariacyCyprusczCzech RepublicdeGermanydkDenmarkeeEstoniaesSpaineuEuropean UnionfiFinlandfrFrancegrGreecehrCroatiahuHungaryieIrelanditItalyltLithuanialuLuxembourglvLatviamtMaltanlNetherlandsplPolandptPortugalroRomaniaseSwedensiSloveniaskSlovakiaukUnited KingdomusUnited States
Who it is for
The module is intended for:
- Magento 2 stores operating in multiple markets;
- installations with multiple store views and websites;
- projects where some language versions operate outside the main storefront;
- teams that want to implement a clear switcher without rebuilding Magento core.
Example use cases
One Magento, multiple store views
The store has the following versions:
PLENDE
Each of them can have a separate flag and label assigned.
One Magento, multiple websites
The store uses separate websites for different countries, for example:
- Poland
- Germany
- France
The module allows these websites to be shown in the same switcher as local store views.
Distributed storefronts
Some markets operate in a different Magento instance or under a different domain. In such a case, Custom URL Flags allow them to be added to a shared switcher.
Implementation result
The customer gets one consistent language and market switcher, and the administrator can manage it from the Magento configuration without creating additional frontend components.
Installation and configuration guide for the Magento 2 Language Flags module
Installation
Installation via Composer
composer require kowal/module-language-flagsbin/magento module:enable Kowal_LanguageFlagsbin/magento setup:upgradebin/magento cache:flushInstallation from the Git repository
composer config repositories.kowal-language-flags vcs https://github.com/kowalco/language-flagscomposer require kowal/module-language-flagsbin/magento module:enable Kowal_LanguageFlagsbin/magento setup:upgradebin/magento cache:flushAdditional commands for production mode
bin/magento setup:di:compilebin/magento setup:static-content:deploy -fbin/magento cache:flushConfiguration location
Admin panel:
Stores > Configuration > Kowal > Language FlagsCMS editor widget
The module provides the following widget:
Language Flags SwitcherIt can be inserted in:
Content > BlocksContent > Pages
Editor path:
Edit > Insert Widget > Language Flags SwitcherThe widget supports:
dropdownorinlinemode;- showing or hiding language names;
- an additional CSS class.
Default flags
During bin/magento setup:upgrade, the module copies default SVG files from:
view/frontend/web/images/flags/to the directory:
pub/media/language_flags/Only missing files are copied, without overwriting existing flags.
General configuration
The General Settings section contains fields that control the module behavior.
Enable Module
Path:
language_flags/general/enabledMeaning:
Yesenables the module;Nodisables the module on the frontend.
Replace Native Store View Switcher
Path:
language_flags/general/native_enabledMeaning:
Yesreplaces the native Magento switcher with a flag version;Noleaves the native switcher unchanged.
Native Display Mode
Path:
language_flags/general/native_display_modeAvailable options:
dropdowninline
Meaning:
dropdownshows the current item and a dropdown list of the remaining ones;inlineshows all flags at once in a single line.
Show Language Names
Path:
language_flags/general/show_labelsMeaning:
Yesshows language names next to flags;Nohides the names in the main view, but keeps them for accessibility.
Fallback to Store View Name
Path:
language_flags/general/fallback_to_store_nameMeaning:
Yesuses the store view name whenLabelis not filled in;Nouses the store view code in uppercase.
Inline Flag Gap (px)
Path:
language_flags/general/inline_gapMeaning:
- sets the spacing between switcher elements in
inlinemode; - the value is measured in pixels;
- the default value is
8.
Icon Scale (%)
Path:
language_flags/general/icon_scale_percentMeaning:
100preserves the original image dimensions;- a lower value reduces width and height proportionally;
- scales flags in both rendering modes.
Configuration of flag tables
The module supports three separate sets of entries:
Store View FlagsWebsite FlagsCustom URL Flags
On the frontend, the entries are combined into one set of switcher elements.
Store View Flags
Path:
language_flags/general/flag_configPurpose:
Configuration of flags for store views handled by the native Magento mechanism.
Form columns
Store Code
Selects a store view from the Magento list.
Meaning:
- assigns a flag to a specific store view;
- uses the native Magento store view switching mechanism.
Flag File
The path to the flag file selected from the built-in file picker.
Meaning:
- defines the image displayed on the frontend;
- can be saved as
pl.svgorlanguage_flags/pl.svg; - relative paths are resolved from the directory:
pub/media/language_flags/Label
The full language or market name, for example:
PolishEnglishGerman
Meaning:
- is displayed next to the flag when
Show Language Namesis enabled; - also serves as helper text for accessibility.
Short Label
A shortened label, for example:
PLENDE
Meaning:
- is used in a more compact view;
- can be used instead of the full name.
Website Flags
Path:
language_flags/general/website_flag_configPurpose:
Configuration of flags pointing to other websites in the same Magento instance.
How it works
- clicking does not perform the native
store switch post; - the entry is rendered as a regular link to the target website base URL;
- the current website is not added as a separate option.
Form columns
Website
Selects a Magento website from the list.
Meaning:
- defines the target website for the entry;
- is used to retrieve the base URL of the target storefront.
Flag File
Works the same as in Store View Flags.
Label
The full label displayed on the frontend.
If left empty:
- the module will use the website name.
Short Label
A shortened label, for example:
UKDEFR
If left empty:
- the module will use the website code in uppercase.
Custom URL Flags
Path:
language_flags/general/custom_url_flag_configPurpose:
Configuration of flags pointing to any URLs, for example to another Magento instance or an external store.
Form columns
URL
The target link address.
Examples:
https://example.de/https://en.example.com/https://shop.example.cz/
Meaning:
- the entry is rendered as a regular
hreflink; - it does not use the native Magento store switch mechanism.
Flag File
Works the same as in the other tables.
Label
The full label displayed on the frontend.
If left empty:
- the module will try to use the host from the URL.
Short Label
A shortened label for the compact variant.
If left empty:
- the module will build a shortcut based on the host;
- if that is not possible, it will use the
URLvalue.
Preparing flag files
Recommended location:
pub/media/language_flags/Recommended formats:
svgpng
Examples of file names:
pl.svgen.svgde.svgfr.svgBasic configuration flow
- Enable the module via
Enable Module. - Decide whether you want to replace the native Magento switcher.
- Set
Native Display Mode. - Add flag files to
pub/media/language_flags/. - Complete
Store View Flags. - Add optional entries in
Website Flags. - Add optional entries in
Custom URL Flags. - Save the configuration and clear the cache.
Useful CLI commands
bin/magento module:status Kowal_LanguageFlagsbin/magento cache:cleanbin/magento cache:flush























