DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

DNN Platform Site localization

 34 Replies
 2 Subscribed to this topic
 25 Subscribed to this forum
Sort:
Page 2 of 4 << < 1234 > >>
Author
Messages
Ram
New Around Here
Posts: 6
New Around Here
Hello,

I need some more information regarding skins and localization.

I have the following skin file we use - Home-Standard.ascx (Portals\_default\Skins\SiteName)

I have created the following 2 resource files (en-us and fr-fr)

[code] Welcome, value> [/code]

[code] Accueil, value> [/code]

In the Home-Standard.axcx file, I am trying to add this snippet:

[code] <dnn:TEXT runat="server" id="dnnTEXT-Welcome" Text="Welcome, " CssClass="NormalBold" ResourceKey="Welcome.Text" ReplaceTokens="False" />[/code]

How do I make this work? I am facing issues in using/rendering localized content based on resources.

Please advice.
Veteran Member
Posts: 360
Veteran Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Posted By Ram on 3/8/2024 12:10 PM
Hello,

I need some more information regarding skins and localization.

I have the following skin file we use - Home-Standard.ascx (Portals\_default\Skins\SiteName)

I have created the following 2 resource files (en-us and fr-fr)

[code] Welcome, value> [/code]

[code] Accueil, value> [/code]

In the Home-Standard.axcx file, I am trying to add this snippet:

[code] <dnn:TEXT runat="server" id="dnnTEXT-Welcome" Text="Welcome, " CssClass="NormalBold" ResourceKey="Welcome.Text" ReplaceTokens="False" />[/code]

How do I make this work? I am facing issues in using/rendering localized content based on resources.

Please advice.

 

In your User Control (Home-Standard.ascx) located at ~\Portals\_default\Skins\SkinName you will probably need something like the following:

<code>protected string GetHomeStandardLocalResourceFilePath() {<br />   return PortalSettings.ActiveTab.SkinPath + Localization.LocalResourceDirectory;<br /> }</code>

Make sure your Home-Standard.ascx.resx file is in ~\Portals\_default\Skins\SkinName\App_LocalResources.

Then wherever you need to access resource keys, you can use the following:

<code>&lt;%= Localization.GetString(&quot;Welcome&quot;, GetHomeStandardLocalResourceFilePath()) %&gt;</code>

 

 

David Poindexter


Creator:


Veteran Member
Posts: 349
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Oh, using the Text skinobject you don't need that code, you just need to have that key in a resource file for your skin.

Assuming your skin is called "MySkin", you can copy any .resx file you find in any DesktopModules\***\App_LocalResources keep most of the xml but delete all the keys and add a key you need. Then rename that file MySkin.resx and place it in \Portals\_default\Skins\MySin\App_LocalResources folder.

After that in DNN Servers, hit the clear cache button so DNN notices that change.

FInaly you can go to your Portal Settings => Languages => Edit Icon (symbols) next to the language to translate
In the resources file dropdown you will find this new file under Site Templates => Skins => MySkin => App_LocalResources => MySkin

You can localize that for all your languages.
Veteran Member
Posts: 360
Veteran Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Oh that's really cool. After all these years, I still learn something new nearly every day! Thanks for sharing that Daniel!

David Poindexter


Creator:


Senior Member
Posts: 1607
Senior Member
MVP
MVP
You're an MVP!
New Poster
New Poster
Congrats on posting!
Posted By Daniel Valadas on 3/8/2024 3:32 PM
Oh, using the Text skinobject you don't need that code, you just need to have that key in a resource file for your skin.

Assuming your skin is called "MySkin", you can copy any .resx file you find in any DesktopModules\***\App_LocalResources keep most of the xml but delete all the keys and add a key you need. Then rename that file MySkin.resx and place it in \Portals\_default\Skins\MySin\App_LocalResources folder.

After that in DNN Servers, hit the clear cache button so DNN notices that change.

FInaly you can go to your Portal Settings => Languages => Edit Icon (symbols) next to the language to translate
In the resources file dropdown you will find this new file under Site Templates => Skins => MySkin => App_LocalResources => MySkin

You can localize that for all your languages.

I'm filing this under "things I used to know but forgot years ago"... Wow!  Nice suggestion, Daniel.  I would've totally been doing what David suggested. 

 

Veteran Member
Posts: 349
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Also that value can contain tokens, so you could do stuff that is both localized and customize, like:

Welcome, [User:FirstName]

Most tokens here will work https://docs.dnncommunity...nt-tokens/index.html
Veteran Member
Posts: 360
Veteran Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Cool intel right there!

David Poindexter


Creator:


Senior Member
Posts: 1607
Senior Member
MVP
MVP
You're an MVP!
New Poster
New Poster
Congrats on posting!

And this is a great example of why I sponsor both of you on GitHub!  💪🏽 

Veteran Member
Posts: 360
Veteran Member
Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
MVP
MVP
You're an MVP!
Posted By Will Strohl on 3/9/2024 3:35 PM

And this is a great example of why I sponsor both of you on GitHub!  💪🏽 

Much appreciated Will! 💙🎉

 

David Poindexter


Creator:


Ram
New Around Here
Posts: 6
New Around Here

Thanks a lot for the detailed explanation. I tried the following 2 ways in Home-Standard ASCX skin file. Cleared the cache and nothing is showing up in the front-end. What am I missing?

1) <%= Localization.GetString("Welcome", "C:\Sites\SITENAME\Portals\_default\Skins\SITENAME\App_LocalResources\Home-Standard") %> 
2)  <asp:Label ID="lblDisplayValue" runat="server" ResourceKey="Welcome.Text" />

Also, the following 2 resx files (Home-Standard.ascx and Home-Standard.fr-FR.ascx) are placed under - C:\Sites\SITENAME\Portals\_default\Skins\SITENAME\App_LocalResources\

 
    Welcome>
 

--------------------------------------------------------------------------  


    Accueil>
 

 

 

Page 2 of 4 << < 1234 > >>

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved