Skip to main content
Signocore
// signocore multilanguage docs

Shortcodes, blocks and widgets

Every shortcode, block and widget in Signocore Multilanguage with its attributes and defaults.

Signocore Multilanguage has two shortcodes, a block and a classic widget, and it can add the language switcher to your menus. The block, the widget, the [signocore_language_switcher] shortcode and the PHP function signocore_language_switcher() all render the same switcher, each with its own settings. The menu switcher takes its look from Signocore ML > Switcher. For placing the switcher and styling it, see Language switcher.

Language switcher shortcode

[signocore_language_switcher]

Shows the language switcher. You can place it in a Shortcode block, in the classic editor, in a text widget or in a theme template:

<?php echo do_shortcode('[signocore_language_switcher style="inline"]'); ?>

In a template, calling signocore_language_switcher() directly does the same with an array of arguments; see Template functions. The shortcode is only registered on front-end requests, so content rendered in wp-admin or through admin-ajax.php shows it as plain text; use the function there.

Attribute Default Allowed values
style dropdown dropdown, list, flags or inline. Any other value gives dropdown.
display Empty native, name, code, short_code or none. When empty, show_names and show_native_names decide.
show_flags true true or false.
show_names true true or false. With false, the languages have no text, unless display is set.
show_native_names true true or false. With false, the English names are shown, unless display is set.
show_current true true or false. With false, the current language is left out of the list.
skip_missing true true or false. With true, languages without a published translation of the current post or page are left out.
class Empty One extra CSS class for the wrapper.

For the attributes that take true or false, the values 1, yes and on also count as true, and anything else counts as false. The class attribute keeps letters, digits, hyphens and underscores only, so it holds a single class name.

The display values choose the text next to each flag:

Value Text Example for Mexican Spanish
native The native name Español (México)
name The English name Spanish (Mexico)
code The language code in capitals ES-MX
short_code The code without its region, in capitals. When another active language shares that short code, the full code is used, so two languages never read the same. ES, or ES-MX when Spanish (es) is active too
none No text

For example, short codes without flags, separated by a line:

[signocore_language_switcher style="inline" display="short_code" show_flags="false"]

And flags only, without the current language:

[signocore_language_switcher style="flags" show_current="false"]

Styles and markup

Style What it shows
dropdown A button with the current language that opens a list of all languages. It opens on click and works with the keyboard: arrow keys, Home, End and Escape. With show_current="false", the current language stays on the button but leaves the list.
list All languages side by side in a list. Called Horizontal List in the block and widget settings.
flags Flags only, 24 by 16 pixels, with the language name in the title attribute. display, show_names and show_flags have no effect.
inline All languages on one line, separated by a vertical bar.

The switcher is wrapped in <div class="sml-switcher sml-switcher-{style}">, plus your class. Each language is an a.sml-switcher-link with hreflang and data-lang attributes, and the current language is a span.sml-switcher-link.sml-active rather than a link. Flags are img.sml-flag elements, 21 by 14 pixels outside the flags style, with the English language name as alt text, and the text is a span.sml-lang-name. The plugin loads the switcher's stylesheet and script on every front-end page.

A language links to the translation of the page you are on. Where there is no translation, and on archives and search results, it links to the same address in that language. The switcher shows nothing when no language is left to show. Developers can change the links with signocore_ml_language_links and the output with signocore_ml_switcher_html.

String shortcode

[sml_string context="Footer" name="cta" default="Book a free call"]
[sml_string context="Footer" name="cta"]Book a free call[/sml_string]

Shows a translatable string in the visitor's language. Both lines above do the same: the source text goes in default, or between the opening and closing tags.

Attribute Default What it does
context Custom The group the string belongs to on the String Translation screen.
name None, required The name of the string within its context. Without a name the shortcode shows nothing.
default Empty The source text in the default language. When empty, the text between the tags is used, and without that, the source text saved for the string.

In the default language, the shortcode shows the source text from the shortcode itself, or, when it has none, the source text saved for the string on the String Translation screen. In another language it shows the translation saved under Signocore ML > String Translation, or the source text when there is no translation yet. The shortcode shown after you use Add a string has only context and name and works as it is. A shortcode without source text shows nothing while its string does not exist on the site, and it cannot add the string by itself.

The first time a page with the shortcode is viewed, the string is added to the String Translation list, as a single line or, when the text has line breaks, as longer text. That happens only for a string that is not registered yet and has a source text, not in previews, and, for a shortcode in a post, only when the post's author can edit other people's posts, as Editors and Administrators can. Changing the source text in the shortcode later does not update the registered string.

The output is plain text: HTML in the text is escaped, and shortcodes inside it are not run. In PHP, use signocore_ml_translate_string(); see String translation for translating strings.

Language Switcher block

Add the Language Switcher block from the Signocore category. It works in posts and pages, and in the templates and template parts of a block theme, such as a header. The editor shows a live preview. The Settings panel has three options:

Setting Default What it does
Style Dropdown Dropdown, Horizontal List, Flags Only or Inline, the same styles as the shortcode.
Language text Native name (Dansk) Native name, English name, Language code, Short language code or No text, like display in the shortcode.
Show flags On Shows a flag before each language.

The block always lists the current language and leaves out languages without a published translation of the current post or page. Classes you add under Advanced > Additional CSS class(es) go on the switcher's wrapper, and so does alignleft, aligncenter or alignright when you align the block left, center or right. The block is rendered on the server, so its markup is the same as the shortcode's.

Language switcher widget

For themes with classic widget areas, add Signocore Language Switcher under Appearance > Widgets. In a widget area that uses blocks, the Language Switcher block does the same. The widget has four fields:

Field Default What it does
Title Empty Heading above the switcher, shown with your theme's widget title markup. Leave it empty for no heading.
Style Dropdown Dropdown, Horizontal List, Flags Only or Inline.
Show flags On Shows a flag before each language.
Language text Native name (Dansk) Native name, English name, Language code, Short language code or No text.

Like the block, the widget always lists the current language and leaves out languages without a published translation of the current post or page. Its class name is widget_sml_language_switcher, which most themes add to the widget's wrapper.

Switcher in menus

The plugin can add the languages to menus that your theme prints with wp_nav_menu(). Set it up under Signocore ML > Switcher:

Setting Card Default What it does
Add to Menus Menu Integration None The menus to add the languages to. A translated menu gets them too, when it is shown in place of a selected menu in another language.
Position Menu Integration End of menu End of menu or Start of menu.
Switcher Style Language Switcher Dropdown How the languages appear in the menu, see below.
Show Flags Language Switcher On Shows a flag before each language.
Language Text Language Switcher Native name (Dansk) on new sites The text next to each flag, with the same choices as the block.

The three settings on the Language Switcher card only apply to menus. The block, widget and shortcode have settings of their own.

In a menu, the styles work like this:

Style Menu items
Dropdown One item showing the current language, with a sub-menu of all languages. It uses your theme's sub-menu styling.
Horizontal List One item per language, with its flag and text.
Inline The same, with a vertical line (span.sml-separator) at the start of every item but the first.
Flags Only One item per language with only its flag, and the name in the title attribute.

The menu switcher always leaves out languages without a published translation of the current post or page, and adds nothing when only one language would be left. Its items are ordinary menu items with the classes menu-item and sml-menu-switcher-item, plus current-menu-item for the current language, which is shown as text rather than a link. Each language link has hreflang and data-lang attributes, and clicking one remembers the language in the visitor's language cookie, as the other switchers do. When a language would have neither a flag nor text, its English name is shown.

A menu is matched by the menu or the theme location the theme passes to wp_nav_menu(). A menu printed by its name or slug without a theme location is not matched. The Navigation block of block themes does not use wp_nav_menu(), so place the Language Switcher block in the header template instead.

Stuck on something the docs don't cover?

Questions go straight to the developer who builds the plugins. Replies usually within a day.

September Sale

€20 off Signocore SEO Pro

Pay €49 instead of €69, one time for unlimited sites. code SEP20