Writing to GlobalResources.dll RRS feed

  • Question

  • User378052101 posted

    Hello there,


    A bi-directional Wep Application that supports Arabic & English and leverages GlobalResources, with 3 distinct resource files; 2 versions of each.

    In a dedicated aspx page, users are facilitated to modify most localised annotations used across the application, and in both languages. Below is the procedure used to extract relevant resources and then casted to respective page controls (TextBoxes):

    Imports System.Globalization

    Private Sub GetSystemLabels()
    ' 1. Locate & Store TextBoxes to hold System Labels

    Dim engTextBoxes, altTextBoxes As New ArrayList()

    For Each childControl As Control In rpv_Labels.Controls
    If TypeOf childControl Is TextBox Then
    Dim foundTBX As TextBox = DirectCast(childControl, TextBox)
    If foundTBX.ID.EndsWith("_Eng") Then
    ' TextBox is English-oriented:
    ' >> Add it to respective ArrayList

    ' TextBox is Alternate-oriented (e.g. Arabic):
    ' >> Add it to respective ArrayList

    End If
    End If


    ' 2. Define & Obtain the source of Labels' Resource Keys
    ' 2.1 Define an Instance of Resource Manager
    ' ---------------------------------------------------

    Dim resManager As System.Resources.ResourceManager = _
    New System.Resources.ResourceManager("Resources.LabelNames", Reflection.Assembly.Load("App_GlobalResources"))

    ' 2.2 Define 2 Cultures as representative to both UI Cultures used
    ' ---------------------------------------------------

    Dim engCulture As CultureInfo = New CultureInfo("en-GB", False)
    Dim altCulture As CultureInfo = New CultureInfo("ar-OM", False)

    ' 2.2 Set Resource Keys to retrieve
    ' ---------------------------------------------------

    Dim resKeys() As String = {"org01_Unit", "org02_Div", "org03_Dept", "org04_Sec", _
    "sch17_EmpName", "emp01_EmpNo", "emp10_IDCard", _
    "sch18_Date", "sch15_FromDate", "sch16_ToDate"}

    Dim fieldsCount As Integer = resKeys.GetUpperBound(0)

    ' 2.3 Iterate and Fetch Resource Keys then
    ' assign their Values to respective TextBoxes
    ' ---------------------------------------------------

    For keyIndex As Integer = 0 To fieldsCount
    Dim engTBX As TextBox = engTextBoxes(keyIndex)
    Dim altTBX As TextBox = altTextBoxes(keyIndex)

    Dim engResValue As String = resManager.GetString(resKeys(keyIndex), engCulture)
    Dim altResValue As String = resManager.GetString(resKeys(keyIndex), altCulture)

    engTBX.Text = engResValue
    altTBX.Text = altResValue
    Next keyIndex

    End Sub


    1. How to write back modified values into resource file in question?
    2. When compiled, I noticed that VS2008 always collects the 3 resource files into a single GlobalResources.dll, which indicates that changing resource values can no longer be saved. Is there a way to sort this out? e.g. not to compile resources?

    Many thanks in advance.


    Wednesday, October 7, 2009 3:35 PM

All replies

  • User378052101 posted

    Well, anyone?


    Saturday, October 17, 2009 11:45 PM