Jump to content

Using language icons


Recommended Posts

I try to display flag icons in Page templates. E. g. for German

<i class="ipsFlag ipsFlag-de"></i>

It does not work and displays nothing. The reason is, that I do have only one language installed. In system/Dispatcher/Standard.php you do not load a CSS in this case:

if ( \count( \IPS\Lang::languages() ) > 1 )
{
	\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'flags.css', 'core', 'global' ) );
}

What is the reason for not loading this CSS on the projects with only one language installed? 

Link to comment
Share on other sites

23 minutes ago, Sonya* said:

What is the reason for not loading this CSS on the projects with only one language installed? 

The flags are used for the language selector dropdown. If there is just one language, there is no language drop-down and no need to load the flags. 

Link to comment
Share on other sites

6 minutes ago, opentype said:

no need to load the flags

Use case

I have created a Pages database similar to Providers. This database has a select field, where the provider can choose a language for communication, e.g. German, Russian, Ukrainian.

I would like to display their language selection in template as flags.

Edited by Sonya*
Link to comment
Share on other sites

37 minutes ago, Sonya* said:

Use case

I have created a Pages database similar to Providers. This database has a select field, where the provider can choose a language for communication, e.g. German, Russian, Ukrainian.

I would like to display their language selection in template as flags.

Just include the flags.css file manually

Link to comment
Share on other sites

What he said.

If you're still worried about it you can just do this in your code:

if ( \count( \IPS\Lang::languages() ) == 1 )
{
	\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'flags.css', 'core', 'global' ) );
}

 

Check if there is only 1 language and then add the CSS file. If you ever add a new language the count will not be 1 and the default code you pasted will kick in instead.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...