Developer forum

Forum » Swift » DW10 Swift 2 - Country Name Instead of Language + Flag Visibility

DW10 Swift 2 - Country Name Instead of Language + Flag Visibility

Ferri Halfhide
Reply

Hi,

In the header and footer, I’ve used Preferences to add a language switch.

This works as expected in terms of functionality, but I noticed something odd:

As shown in the screenshot below, the country name (“België”) is displayed instead of the language.

What I’d like to achieve is that the language name is shown — for example, “Nederlands” instead of “België” - just like in the selector.

I’m using Swift 2. Any idea where or how I can adjust this?

Additionally, I’ve noticed that the country flag is shown for some languages but not for others.

How can I add a flag for languages or countries where it’s currently missing?

Thanks in advance!


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi

The language selector actually shows a list of language websites and use the name of the language website - and not the name of the language used by that website.

You can easily modify the template to use the name of the language used for that website - locate the template Files\Templates\Designs\Swift-v2\Paragraph\Swift-v2_Preferences\Offcanvas.cshtml and change L129-130 to this (https://github.com/dynamicweb/Swift/blob/93dbc3f701aac342bed816470d45b2c2e70d2485/Files/Templates/Designs/Swift-v2/Paragraph/Swift-v2_Preferences/Offcanvas.cshtml#L129)

var languageRegion = new System.Globalization.RegionInfo(language.Area.CultureInfo.LCID);
<option hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId"
        @selectedLanguage>@languageRegion.DisplayName</option>

You can add missing flags to /Files/Images/Icons/Flags/ - let me know which you are missing.

BR Nicolai

 
Ferri Halfhide
Reply

Hi,

Thank you for the information — that worked!

However, regarding the flags: I’m still missing the flags for Belgium and France.

When I check the directory, I can see that the nl-BE flag has been added, but it’s still not showing on the front-end.

 
Ferri Halfhide
Reply

Hi,

Thank you for the information — that worked!

However, regarding the flags: I’m still missing the flags for Belgium and France.

When I check the directory, I can see that the nl-BE flag has been added, but it’s still not showing on the front-end.

 
Ferri Halfhide
Reply

Hi, 

Is there any way to solve this?

"Additionally, I’ve noticed that the country flag is shown for some languages but not for others."

How can I show a flag for countries where it’s currently missing in the frontend, even though they are added in backend?

Thanks in advance!

 
 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply

Hi Ferri

Sorry for the late reply. I just chekced the code that renders the flag. It is very simple. You could try lowercasing the filename "nl-be.svg". And check that the svg exist on the server by adding the filepath to the url: YOURSITE/files/Images/Icons/Flags/nl-be.svg

For you reference, this is the flag rendering code:

string flagIconFolder = "/Files/Images/Icons/Flags/";
    if (Model.Item.GetBoolean("UseLanguageIcon"))
    {
        pageIcon = $"{flagIconFolder}{region.Name}.svg";
    }

 

You must be logged in to post in the forum