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.

 

You must be logged in to post in the forum