Language Translation and VB.NET 
Author Message
 Language Translation and VB.NET

Hello,

I am a newbie to VB.NET.  I my previous language to translate literals we
would wrap a function around the text passing the string, id of the string
in the dll, and the dll filename ...

Example:

Globale variable would be set when app starts:
gsLanguage = 'LanuageSpanish.DLL'

..
..
..

sTranslatedString = LoadResString( "Test", 10023, gsLanguage )

... is there a better way to do this in the .Net world?

Any help or input would be greatly appreciated.

Thanks,
Rob Panosh
Advanced Software Designs



Sun, 23 Oct 2005 04:33:33 GMT  
 Language Translation and VB.NET
If you set the form's "Localizable" property to True, this is handled
automatically. All you have to do is translate the form's controls after
setting it to the desired language. For text not on design-time controls
(such as dynamically created controls and messages) you'll have to create
resource files with the translated strings and load them through the
System.Resources.ResourceManager.GetString(...) call. The current language
itself is set through the
System.Threading.Thread.CurrentThread.CurrentUICulture property. Once the
"culture" property has been set, the GetString call will retrieve the
correct language version (or default to the "neutral" language if it's not
found).

It's quite well documented in the help and samples.
--
Pierre Szwarc
Paris, France
PGP key ID 0x75B5779B
------------------------------------------------
Science is true. Don't be misled by facts.
------------------------------------------------


| Hello,
|
| I am a newbie to VB.NET.  I my previous language to translate
| literals we would wrap a function around the text passing the string,
| id of the string in the dll, and the dll filename ...
|
| Example:
|
| Globale variable would be set when app starts:
| gsLanguage = 'LanuageSpanish.DLL'
|
| ..
| ..
| ..
|
| sTranslatedString = LoadResString( "Test", 10023, gsLanguage )
|
|
| ... is there a better way to do this in the .Net world?
|
| Any help or input would be greatly appreciated.



Sun, 23 Oct 2005 17:00:29 GMT  
 Language Translation and VB.NET
Pierre,

Thanks for the help.

Regards,
Rob Panosh


Quote:
> If you set the form's "Localizable" property to True, this is handled
> automatically. All you have to do is translate the form's controls after
> setting it to the desired language. For text not on design-time controls
> (such as dynamically created controls and messages) you'll have to create
> resource files with the translated strings and load them through the
> System.Resources.ResourceManager.GetString(...) call. The current language
> itself is set through the
> System.Threading.Thread.CurrentThread.CurrentUICulture property. Once the
> "culture" property has been set, the GetString call will retrieve the
> correct language version (or default to the "neutral" language if it's not
> found).

> It's quite well documented in the help and samples.
> --
> Pierre Szwarc
> Paris, France
> PGP key ID 0x75B5779B
> ------------------------------------------------
> Science is true. Don't be misled by facts.
> ------------------------------------------------



> | Hello,
> |
> | I am a newbie to VB.NET.  I my previous language to translate
> | literals we would wrap a function around the text passing the string,
> | id of the string in the dll, and the dll filename ...
> |
> | Example:
> |
> | Globale variable would be set when app starts:
> | gsLanguage = 'LanuageSpanish.DLL'
> |
> | ..
> | ..
> | ..
> |
> | sTranslatedString = LoadResString( "Test", 10023, gsLanguage )
> |
> |
> | ... is there a better way to do this in the .Net world?
> |
> | Any help or input would be greatly appreciated.



Sun, 23 Oct 2005 20:35:07 GMT  
 Language Translation and VB.NET
YW :) I did it recently, and I'm a total newbie with .Net also. It took me a
couple of hours to locate and implement all the{*filter*}details. When you
create a form and set it as Localizable, you'll notice the IDE creates a
resource file named {formname}.resx. When you set the form to a different
language (for example, "French(France)", it will create a copy of the
resource file named {formname}.fr-FR.resx. While the form is set as French,
translating, moving and resizing the controls will update that file. When
you build the project, you will get a set of files all named
{projectname}.resources.dll, each in a subdirectory bearing the name of the
corresponding "culture". The "default" culture is taken from the IDE's
language (in your case, probably "en-US"). Changing the program's culture
before the form is loaded (in the form class initialization code or in the
Main subroutine) makes it select the appropriate subdir to load the resource
DLL from. It sounds more complex than it really is. .Net uses "culture"
instead of "language" because it also controls the formats for numbers,
currency and date/time strings. As a matter of fact, you'll find that
storing date and time values in a culture-independant way (for international
apps and/or databases) is a chore.
--
Pierre Szwarc
Paris, France
PGP key ID 0x75B5779B
------------------------------------------------
Science is true. Don't be misled by facts.
------------------------------------------------


| Pierre,
|
| Thanks for the help.



Sun, 23 Oct 2005 22:02:27 GMT  
 Language Translation and VB.NET
Ohh. I have been looking for that Thanks!

Do you know or anyone how to best deal with message boxes and Error messages
(Exceptions)

Regards
Fredrik Melin


Quote:
> YW :) I did it recently, and I'm a total newbie with .Net also. It took me
a
> couple of hours to locate and implement all the{*filter*}details. When you
> create a form and set it as Localizable, you'll notice the IDE creates a
> resource file named {formname}.resx. When you set the form to a different
> language (for example, "French(France)", it will create a copy of the
> resource file named {formname}.fr-FR.resx. While the form is set as
French,
> translating, moving and resizing the controls will update that file. When
> you build the project, you will get a set of files all named
> {projectname}.resources.dll, each in a subdirectory bearing the name of
the
> corresponding "culture". The "default" culture is taken from the IDE's
> language (in your case, probably "en-US"). Changing the program's culture
> before the form is loaded (in the form class initialization code or in the
> Main subroutine) makes it select the appropriate subdir to load the
resource
> DLL from. It sounds more complex than it really is. .Net uses "culture"
> instead of "language" because it also controls the formats for numbers,
> currency and date/time strings. As a matter of fact, you'll find that
> storing date and time values in a culture-independant way (for
international
> apps and/or databases) is a chore.
> --
> Pierre Szwarc
> Paris, France
> PGP key ID 0x75B5779B
> ------------------------------------------------
> Science is true. Don't be misled by facts.
> ------------------------------------------------



> | Pierre,
> |
> | Thanks for the help.



Sun, 23 Oct 2005 22:20:21 GMT  
 Language Translation and VB.NET
Create a set of resource files (project|add|new item|Windows Resource file)
named (for example) Strings.resx, Strings.en-US.resx, Strings.fr-FR.resx,
etc... Create a local Resource manager like this:

    Public rscResource As New
System.Resources.ResourceManager("{PRoot}.Strings", _
    System.Reflection.Assembly.GetEntryAssembly())

Where {PRoot} is the root namespace as defined in the project property page
(by default, the project name)
Then you can load each string with this call:

    strMesg = rscResource.GetString("{stringName}")

Where {StringName} is the (case sensitive) name you gave the string in the
resource file(s). The quotes are part of the syntax. Again the language will
be chosen at run time according to the "culture". The resource file without
a culture identifier (Strings.resx) is mandatory, it will be used as the
default, fall-back resource if a string name isn't found in the translated
file. IOW, you only need to put in the translated files the strings that do
change from one language to the other. For example, the word "Options" is
the same in English and French, so the Strings.fr-FR.resx file doesn't need
to contain it.
--
Pierre Szwarc
Paris, France
PGP key ID 0x75B5779B
------------------------------------------------
Science is true. Don't be misled by facts.
------------------------------------------------


| Ohh. I have been looking for that Thanks!
|
| Do you know or anyone how to best deal with message boxes and Error
| messages (Exceptions)



Mon, 24 Oct 2005 01:31:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Third party multi language translation tools

2. Language translation

3. VB.NET Locales/Languages Issue

4. vb.net c# language mapping conversion

5. Fill a dropdownlist Dynamically in .Net aspx (VB language)

6. Vb.net language reference

7. Trouble in asp.net vb language

8. Is VB.Net a true OO Language?

9. Confirmation of VB.NET Language Changes

10. Q844321: PRB: VB.NET Beta 1 is a consistent language

11. Enhancements to the VB language and .NET CLR before release

12. VB.net a new language?

 

 
Powered by phpBB® Forum Software