473,765 Members | 2,028 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(Strin g Name)
{
XmlNode node;
node = X.SelectSingleN ode
("//main/language[@id='" +Lang + "']/" + Name);
if (node == null) return "";
else
{
string value =
node.InnerXml.T oString();
return value;
}
}
}
}

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

This object has three methods:

XmlLang::XmlLan g(String FileName, String Language)
XmlLang::XmlLan g(String FileName)
String XmlLang::GetStr ing(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
ConfigurationSe ttings.AppSetti ngs 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(Strin g 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="ut f-8"?>
<main>
< language id ="N">
<name>Naam</ name>
<number>Numme r</number>
<street>Straa t</street>
<country>Land </country>
</ language >
< language id ="E">
<name>Name</name>
<number>Numbe r</number>
<street>Stree t</street>
<country>Countr y</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(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);

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

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

this.StreetLabe l.Text = Lang.GetString( "street");

this.CountryLab el.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*********@br turbo.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.EventArg s) 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.Lab el) Then
varxml = CType(c,system. web.ui.webcontr ols.Label).text
CType(c,system. web.ui.webcontr ols.Label).text =
XmlLang1.GetStr ing(varxml)

End If

Next
End Sub

.


Nov 18 '05 #1
0 1793

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

Similar topics

5
16681
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
4013
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 will grow as large as 370 MB. Rarely will it run to completion; usually, it throws an out of memory...
3
5698
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
6421
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
11967
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
4701
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
3067
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
2106
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 error occurred and this feature is no longer functioning properly - then: Selected collating sequence...
1
3122
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 = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
0
9568
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.