Developer forum

Forum » CMS - Standard features » Change language names in language selecter

Change language names in language selecter

Jonas Nielsen
Reply

Hi,

Is there a way to change and translate the names of the languages that apears in the language selecter? 

1) I want to use the local language name. e.g. "Danish" is the same no matter what language I select.
Preferable this should be "Dansk" - show in the native form and not English. 

2) The Spanish language apears like this: "Spanish, International Sort". I would prefer it to just say "Spanish" as the current name is unnecessarily long.

Language_names.jpg

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jonas

Currently you van only change that directly in the template:

\Files\Templates\Designs\Swift\Swift_Preferences.cshtml

There is this line of code in line 254: 

<span class="align-middle">@language.Area.DisplayName</span>

Which can be changed to one fo these:

<span class="align-middle">@language.Area.Name</span>
<span class="align-middle">@language.Area.Title</span>
<span class="align-middle">@language.Area.CultureInfo.NativeName</span>

Using either the name of the website from the backend, the title specified on the website settings or the "Native name" of the region info selected on the website settings.

The last option will give you the name of the country in its native name - and some additiional info. You might be able to do this to get only the name:

<span class="align-middle">@language.Area.CultureInfo.NativeName.Split('(')[0].Trim()</span>

BR Nicolai

Votes for this answer: 1
 
Jonas Nielsen
Reply

Hi Nicolai,

Thank you for your answer. THat helped for the Drop down list.

Is it possible to also the same for the modal used on mobile? Is this somewhere in the same file? 

Thanks in advance. 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Yes, it is the same template, line 124:

<option hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId" @selectedLanguage>@language.Area.DisplayName</option>

You can change it to this:

<option hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId" @selectedLanguage>@language.Area.DisplayName.Split('(')[0].Trim()</option>

BR Nicolai

Votes for this answer: 1
 
Jonas Nielsen
Reply

Hi Nicolai,

Excellent. It worked. Thank you very much for your help. I appreciate it.

 
Jonas Nielsen
Reply

Hi Nicolai,

I have one final question regarding the language settings.

I noticed that some language names are written in lowercase while others are capitalized. For instance, "dansk" instead of "Dansk" (as shown in the attached screenshot).

It seems that the names visible under "Regional Settings" from the languages settings menu, are the ones appearing on the frontend. (see screenshot)
or example, "dansk" is lowercase, while "Nederlands" is correctly capitalized in this list. Unfortunately, I can't modify the names in that list.

Could you guide me on where I can adjust this?

Thank you in advance for your help!

Skærmbillede_2024-10-14_143825.jpg Sprog.jpg
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

 

Change

<span class="align-middle">@language.Area.CultureInfo.NativeName.Split('(')[0].Trim()</span>

to 

<span class="align-middle text-capitalize">@language.Area.CultureInfo.NativeName.Split('(')[0].Trim()</span>

And change

<option hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId" @selectedLanguage>@language.Area.DisplayName.Split('(')[0].Trim()</option>

to

<option class="text-capitalize" hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId" @selectedLanguage>@language.Area.DisplayName.Split('(')[0].Trim()</option>
 
Jonas Nielsen
Reply

Perfect. I worked on PC. Thanks. 

Somehow it does not work on mobile

 

You must be logged in to post in the forum