Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksLocalization of GridView Including CommandField ButtonsLocalization of GridView Including CommandField Buttons
Previous
 
Next
New Post
4/19/2008 6:31 AM
 

Hi, that's a pretty nice piece of code, i've tried and it worked but it's acting somewhat in my code irregularly can you help me out here? where should i load this function beside the page_load? i put it in the _selectedIndexChanged for each gridview but the text for the command keep switching each time i press select for example  between the default language (US) and the language i'm translating to and the columns header disapear completely !!!!! 

Thank you.

Mazen.

 
New Post
4/23/2008 3:34 AM
 

Hi...

Please let me know what does the localization.getsting wil do?

Is there any method called GetString in your application?

How u r catching the key pair of a resource file?

 

Please respond fast......

 

Thnx in advance.

William Severance wrote

Needing to localize a GridView control's header text as well as the captions on the buttons in a CommandField, I wrote the following:

Public Shared Sub LocalizeGridView(ByVal gv As GridView, ByVal ResourceFile As String)
     Dim key As String
     Dim localizedText As String
     Dim pi As System.Reflection.PropertyInfo

     For Each col As DataControlField In gv.Columns
           key = col.HeaderText
           If key <> "" Then
               localizedText = Localization.GetString(key & ".Header", ResourceFile)
               If localizedText <> "" Then
                   col.HeaderText = localizedText
               End If
           End If

           'Localize text of Cancel, Delete, Edit, Insert, Select, New, Update buttons
           If TypeOf col Is CommandField Then
                Dim cmdField As CommandField = DirectCast(col, CommandField)
                For Each cmdName As String In New String() {"Cancel", "Delete", "Edit", "Insert", "Select", "New", "Update"}
                      pi = cmdField.GetType.GetProperty(cmdName & "Text", GetType(String))
                      key = CType(pi.GetValue(cmdField, Nothing), String)
                      If Not String.IsNullOrEmpty(key) Then
                          localizedText = Localization.GetString(key & ".CommandText", ResourceFile)
                          If localizedText <> "" Then
                               pi.SetValue(cmdField, localizedText, Nothing)
                          End If
                      End If
               Next
          End If
     Next
End Sub

In the local resource file, the keys for Header text should end with .Header while the keys for the CommandField button captions should end with .CommandText. In a CommandField, the EditText, CancelText, etc. default to "Edit", "Cancel", etc. so unless the defaults are overridden in the CommandField declaration, use keys of "Edit.CommandText", "Cancel.CommandText", etc. in the resource file.

I'm not sure if my use of reflection in getting and setting the captions of the CommandField buttons is the most efficient performance wise, it was quick to write using fewer statements.

Hope this is helpful to someone!

 
New Post
4/23/2008 5:37 AM
 

shashi, please check the Localisation Whitepaper and the Module Development Localization Guide, both available from Resources > Documentation > Downloads page in the menu above.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
4/23/2008 6:36 AM
 
Hi.... Thnks fr ur response...I had read the document. But im srry to say tht...i cudnt find the answer . Please tel me as how u'll get the particular key from the resource file. The Getstring method you used is nt present in the document. So please let me know. Thnks in advance shashi
 
New Post
4/23/2008 8:51 AM
 

shashi, Localization.Getstring is a DNN Framework method, part of the Localization Class.

Anyhow, i am not quite sure i am following your question. Can you please elaborate as to why it is you are asking this question? (so we can answer your question better....)


Erik van Ballegoij, Former DNN Corp. Employee and DNN Expert

DNN Blog | Twitter: @erikvb | LinkedIn: Erik van Ballegoij on LinkedIn

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksLocalization of GridView Including CommandField ButtonsLocalization of GridView Including CommandField Buttons


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

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

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. 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.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out