473,513 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multilanguage System (TAKE LABEL NAME) SOS

ok. im try to make a multilanguage system based on that
tutorial :

http://www.123aspx.com/redir.aspx?res=29112

in my aspx pages all text are in labels , and i want to
take the name labels ( in one loop ) and for each label
take on the XML document the right(in the right language)
Value (text).

Above you can see what im doing , it works , however im
trying to make a function that look at all aspx and when
found a LABEL , take the value ( text) from one xml
document like the function in the end of this document.
************************************************** ********

I have created an object that will retrieve the correct
data from an XML file. The code in C# is displayed below.
------------------------------------------------------
using System;
using System.Xml;
namespace diffudessnet
{
public class XmlLang
{
protected XmlDataDocument X;
protected String Lang;
public XmlLang(String FileName,String
Language)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = Language;
}

public XmlLang(String FileName)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = "N";
}
public String GetString(String Name)
{
XmlNode node;
node = X.SelectSingleNode
("//main/language[@id='" +Lang + "']/" + Name);
if (node == null) return "";
else
{
string value =
node.InnerXml.ToString();
return value;
}
}
}
}

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

This object has three methods:

XmlLang::XmlLang(String FileName, String Language)
XmlLang::XmlLang(String FileName)
String XmlLang::GetString(String Name)
To start, we will assume all XML documents are in the same
directory. In this way, they can be made inaccessible to
all users. The path of this directory is hardcoded in the
source of the object. A good alternative is using the
ConfigurationSettings.AppSettings method and saving all
values in the web.config file.

In the first version of the constructor, the name of the
XML file and the selected language are passed to the
constructor. If you want to select a name for the
document, it might be useful to select the same name as
you aspx file. The language parameter is a simple string.
Possible values are "N" for Dutch, "F" for French, "E" for
English, . The format of the XML document will be
discussed later.

The second version of the constructor will automatically
select the Dutch version of the texts. This option is very
handy if you only want to use the Dutch version, and other
languages are only planned for the future.

The method GetString(String Name) will retrieve the text
belonging to the node named Name from the XML file. All
text items in the XML document are marked by keywords. The
value of a keyword is the word in the specified language.
-------------------------------------------
XML Document
<?xmlversion="1.0"encoding="utf-8"?>
<main>
< language id ="N">
<name>Naam</ name>
<number>Nummer</number>
<street>Straat</street>
<country>Land</country>
</ language >
< language id ="E">
<name>Name</name>
<number>Number</number>
<street>Street</street>
<country>Country</country>
</language>
<languageid="F">
<name>Nom</name>
<number>Numméro</number>
<street>Rue</street>
<country>Pays</country>
</language>
</main>


Different languages are separated by the <language
id="languageid" /> tags. The languageid attribute should
be passed to the constructor of the class.
Using the class
Using the object is pretty straightforward. You create a
new instance of the object in the OnInit(.) member
function of your page object. Suppose we have a page
called client.aspx containing client data. The name of the
codebehind file is client.aspx.cs. To make things simple,
we name the xml file client.xml.

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

XmlLang Lang = new XmlLang("client.xml",Session
["LANGUAGE"].ToString());

this.NameLabel.Text = Lang.GetString("name");

this.StreetLabel.Text = Lang.GetString("street");

this.CountryLabel.Text = Lang.GetString("country");
}

Instead of hard-coding all static text in client.aspx, we
use labels as a replacement. In the OnInit member
function, these labels are filled with the right contents,
depending on the selected language. In this example, the
chosen language is stored in a session variable : Session
["LANGUAGE"]. The method as it is mentioned also allows
you to change column headers from a datagrid object.
************************************************** ********
-----Original Message-----
I do something very similar with all labels on a page (though I only use c#so the vb code is difficult for me to follow!). May I ask what actuallyhappens when you run this ? My first thought is that you must make theroutine recursive by calling itself on each sub-control within each toplevel control on the page.

"Giovane Calabrese" <gi*********@brturbo.com> wrote in messagenews:08****************************@phx.gbl...
( aspx + vb )
hi everyone !
I really need make that function work !
im brazilian , and i want to make a multilanguage system , that function above must look at all ASPX take the labels ID and send as a parameter
,... so Please , help me ,.. cause it doest work !

'------------------------------------------------------- --- --------------
' LOAD PAGE
'------------------------------------------------------- --- --------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TraduzLbl(me)

end sub

Sub TraduzLbl(byval parent As Control)
Dim XmlLang1 as new XmlLang
Dim varxml as string
Dim c As Control

For each c In parent.Controls
If c.GetType() is GetType (system.web.ui.webcontrols.Label) Then
varxml = CType(c,system.web.ui.webcontrols.Label).text
CType(c,system.web.ui.webcontrols.Label).text =
XmlLang1.GetString(varxml)

End If

Next
End Sub

.


Nov 18 '05 #1
0 1766

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

Similar topics

5
16657
by: Mariano López | last post by:
I'm trying to make a multilanguage website. When the user enters the site, I want to detect the language and automatically make a redirection. How can I do this? And how should I organize my data base so the user can switch languages easily? Thanks.
1
3987
by: lwickland | last post by:
Summary: System.Net.ScatterGatherBuffers.MemoryChuck allocates inordinately large bytes when sending large post data. The following application consumes inordinate quantities of memory. My code does not explicitly allocate memory in a loop nor does it explicitly allocate large blocks of memory. Yet, the application’s memory footprint...
3
5654
by: Luis Esteban Valencia | last post by:
A page let of work for me I commented almost all lines but nothing the code is this
6
6394
by: Biva | last post by:
Hello All, Please help. I get the following error from my webpage: System.InvalidCastException: Specified cast is not valid. at Time.MaintAtRiskProjects.UpdateProject(String Project, String AtRiskCode, String Comment) Code for UpdateProject(String Project, String AtRiskCode, String Comment) is:
8
11945
by: Aftab Alam | last post by:
Hello All I wanted to know that how can I build an application which takes arabic or urdu input I mean when I type something in my applications edit box it writes arabic. please do let me know about a good tutorial regarding multilanguage support in dot net applicaitons Regards Muhammad Aftab Alam
7
4696
by: Mat | last post by:
I would like to build multilanguage applications -user may have options, in runtime to change the language(switch). -i may need to update languages (grammar..) without rebuild to applications. Or how to write the application in order that user can download language pack as plugin for application Thanks you TIP
5
3033
by: Michal Táborský | last post by:
I am wondering, if it's effective to use text arrays to store multilanguage information. We used to do it like this: CREATE TABLE product ( id serial NOT NULL, price float4, ... )
0
2098
by: HelmutStoneCorner | last post by:
Hi, I am connected as a german client to a multilanguage server, Regional Options: English, US. Western Europe and US. The W2K Server (Terminal) -version: english(US) runs a french database. My regional options are: General: English, US, (Keybd: german). I create a new database and, opening the table or going to the options, I get: An...
1
3100
by: starcandy | last post by:
haii........ ,first at all sorry because im not good in english i want to ask how to add quantity for inventory system .this is my form but it has error... <?php require_once('Connections/inventory.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue =...
0
7269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7394
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7542
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5100
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.