473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with Multi-language site

I am developing a web site at work that needs to be both in French and
English. I have been reading up on using resource files (.resx files) in
combination with setting the CultureInfo to either "en-CA" (Canadian
English) or "fr" (French), then retrieving the appropriate variables from
the resx file with a ResourceManager depending on the current Culture. That
seems straightforwrad enough. Whenever I want a label or any other control
that displays text to display text, I just assign its text value the value
in the resx file. What I would like to do is encapsulate that whole process
so all I need to do is call a sub, for example "setPageText", in an object,
for example "Language", that would do all the labelling of the controls for
me. I thought that maybe I could just have the sub take as a parameter the
entire page. It could then loop through all the controls and set the text
property of each to the right value that is pulled from the resx file. So
the way I see it, all I would have to do in the Page_Load is include this
code:

Dim myLanguage as new Language("myResourceFileName")
myLanguage.setPageText(me)

The code below seems to do the trick for looping through the controls of the
page (it actually seems to loop more times that I would have expected
showing "literal controls" -- does it consider straight html as a literal
control?). However, how can I set the text value of each of the controls if
I don't know what kind of control it is? Basically, any control that has a
text value (label, checkbox, radio button, etc) I would like to set its
value using the resx file. I am moreorless new to ASP.Net and VB.Net, so
perhaps this is an easy question. I guess once I find out what kind of
control it is, I would then cast it to this conrol and then set its text
value? Or is no casting necessary?

Is there some soundness in the general idea of what I am trying to
accomplish, or is there another way that I should be considering? In a
nutshell, I don't want to have to call the ResourceManger's getString()
function everytime I have text that could be in either English or French.

Thanks for any suggestions,
Marcus Bell
*****************************************
Public Class Language
Protected myRM As ResourceManager

Sub New(ByVal myResource As String)
myRM = New ResourceManager(myResource, GetType(junk3).Assembly)
End Sub

Sub setPageText(ByVal myControl As Control)
Dim myType As String
Dim name As String
Dim c As Control
If myControl.HasControls Then
For Each c In myControl.Controls
setPageText(c)
Next
Else
myType = myControl.GetType.ToString
name = myControl.ID
If name <> "" Then
'****** put code here that determines the type of control
that is currently in scope and get the text from the resrouce file
'****** using the ResourceManger class
End If
End If
End Sub
End Class
*****************************************
Nov 19 '05 #1
0 1259

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Silver | last post by:
Hi everyone, my program compiles and executes, but I get an error during run-time. I guess it has something to do with memory allocation (which I don't seem to fully control yet).. Here's the...
7
by: Shane | last post by:
Hi, Thanks in advance for the help. I have been to many websites and tried several solutions to my problem, but have fixed part of it. It's time to come humbly to the newsgroups for help :-) ...
9
by: cheryl | last post by:
I am relatively new to programming in Access for a multi user environment, and am having trouble figuring out if there is a way to accomplish one of our user requests. I am working on a multi...
1
by: Joe | last post by:
I have the following 3 tables: Clients, which has a numeric PK field called CLIENT_ID Languages, which has a numeric PK field called LANGUAGE_ID Client_Languages, which has a unique PK and...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
2
by: deezle | last post by:
Hello, I am trying to get my calculator GUI to +,-,* and /. I have got all of them to work except my division. I was wondering if someone could helpme figure out the problem. Any input would help...
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.