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
 22 Subscribed to this forum
Sort:
Page 2 of 4 << < 1234 > >>
Author
Messages
Ram
New Around Here Send Private Message
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 Send Private Message
Posts: 350
Veteran Member
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:

protected string GetHomeStandardLocalResourceFilePath() {   return PortalSettings.ActiveTab.SkinPath + Localization.LocalResourceDirectory; }

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:

<%= Localization.GetString("Welcome", GetHomeStandardLocalResourceFilePath()) %>

 

 

David Poindexter


Creator:


Advanced Member Send Private Message
Posts: 244
Advanced Member
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 Send Private Message
Posts: 350
Veteran Member
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 Send Private Message
Posts: 1513
Senior Member
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. 

 

Advanced Member Send Private Message
Posts: 244
Advanced Member
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 Send Private Message
Posts: 350
Veteran Member
Cool intel right there!

David Poindexter


Creator:


Senior Member Send Private Message
Posts: 1513
Senior Member

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

Veteran Member Send Private Message
Posts: 350
Veteran Member
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 Send Private Message
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 dedicated to the discussion of DNN Platform.

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