Resource files

  • Thread starter Thread starter raju
  • Start date Start date
R

raju

Hai,

In my application, I am having the option for change language.
For this, I am using one text file as resoucefile. In that i am having
many constant string, which is used to display in the form.

How to read, particular string from that resource file. For eg.,
the file contains 3 strings.

Name : Hello
Location : Here Only
City : this city

If i want city means i have to read city only.

How to do this?

Regards,
Raju.
 
Hello Simon Hart,


I created resource file, in the name of
"ownapplicationEnglish.resx" and using the resgen tool, now i got the
"ownapplicationenglish.resource" file also.

But, how to read the vlaues from that file?.

For another language, whether i have to create another resource
file like this.

Regards,
Raju
 
Hi Raju,

It depends whether you are using VS.NET 2005 or VS.NET 2003.

Read the article I posted for VS.NET 2005. For VS.NET 2003 you need to use
the ResourceManager class for example:

ResourceManager _rm = new ResourceManager("ownapplicationEnglish",
Assembly.GetExecutingAssembly());
string myString = _rm.GetString("myString");

It is much easier in VS.NET 2005 as you simply reference the resource file
as if it were a class. The resource becomes strongly typed.

Note: The naming of your resx file needs to be cultured. So as in your above
example, english would be ownapplication-en.resx. Subcultures such as
american english would be ownapplication-en-US.

The CLR will then automatically load the correct resource file based on the
devices culture.

As for using resgen, you really don't need to use it if you have VS.NET as
it does it for you. Compiling into the .resource file then linking into a
library.

Do a search on MSDN for information about localization/globalization in
Microsoft .NET.

Here is another link that might help:
http://msdn2.microsoft.com/en-us/library/z68135h5.aspx

Regards
Simon.
 
Hello Simon Hart,

Thanks for your prompt reply.

I will read and try with the help given by you, and if any
doubts i will contact through this group.


Regards,
Raju.
 
Back
Top