"Localizing" inherited forms?

N

Nak

Hi there,

I have some inherited forms that I wish to make "localizable",
unfortunately none of the items I wish to be "localizable" are actually
being "localized". For example, I have a few of properties which set the
text of some labels on the form which are inherited from the base form,
these text values aren't "localized" Has anyone any ideas where I'm going
wrong?

Nick.
 
N

Nak

Hi again,

I've found a way round it by making the access modifier for each control
I wish to make localizable "Protected" rather than "Friend", then I can set
the property in the designer directly rather than through my own property.
I was hoping that there would be an attribute that I could set to my own
properties that I wish to be localizable? Thanks for any tips with this in
advance.

Nick.
 
P

Phill. W

Nak said:
I was hoping that there would be an attribute that I could set to my
own properties that I wish to be localizable?

The attribute

System.ComponentModel.BrowsableAttribute(True)

will make the property visible in the Properties window.

HTH,
Phill W.
 
J

Jay B. Harlow [MVP - Outlook]

Nick,
Is the base form in the same assembly or a different assembly?

If the base form is in a different assembly, then as you found you need to
use "Protected" or "Protected Friend" to be able to set a controls
properties in the derived form.

I have not tried it, can't you set the base form to be localizable &
localize just be base form, then localize just the derived form? Although if
you need to rearrange controls, I can see where the derived form would need
to change the location of base controls...

Hope this helps
Jay
 
N

Nak

Hi Jay,
If the base form is in a different assembly, then as you found you need to
use "Protected" or "Protected Friend" to be able to set a controls
properties in the derived form.

Oh that would make sence why I was having problems seeing the objects in
the other assembly.
I have not tried it, can't you set the base form to be localizable &
localize just be base form, then localize just the derived form? Although
if you need to rearrange controls, I can see where the derived form would
need to change the location of base controls...

I'm not quite sure how that works to be honest with you, I was suprised
that it didn't localise in the first place, but then again I suppose all it
is doing is applying localisation to specific controls anyway. Unless of
course it is applying it to anything with the "browsable" attribute as
suggested by Phil. I shall have to take another look. Cheers loads for the
help!

Nick.
 
N

Nak

Hi Phil,
System.ComponentModel.BrowsableAttribute(True)

Hmmm, would take make the property localisable? I'll have to take a
look in a short while. Cheers for the tip and your time, most appreciated.

Nick.
 
J

Jay B. Harlow [MVP - Outlook]

Nick,
I don't know if there is a relationship between BrowsableAttribute &
Localizable.

I would only expect protected or public controls of the base form to be
localizable from the derived form. However I have not tried localizing an
inherited form yet...

Hope this helps
Jay
 
G

Guest

Jay, I've read all I can find on Localization but still don't really
understand it. I think it's a way of using different cultural info for
things like Text Properties. What is meant by Localizing a Form?
 
J

Jay B. Harlow [MVP - Outlook]

Dennis,
Localization is the process of converting your form so it displays correctly
in different cultures (languages). Closely related to Localization is
Globalization.

For example most of my forms are in US English, if someone in Austria wanted
to use my form they would probably want a German - Austria version of the
form, so they would want a form localized to culture "de-AT". However
someone in Germany would probably want a German - Germany form or culture
"de-DE". Now someone in the Netherlands might prefer a "nl-NL" form for
Dutch - The Netherlands...

Localization often entails more then just Text Properties as the placement
of controls can be affected, for example the size of your labels will often
increase (or decrease).

Localization should also entail the text you send in Exceptions, and
possibly the order of words.

For details on Localization see:

http://msdn.microsoft.com/library/d.../vxoriGlobalizationLocalizationNamespaces.asp

http://msdn.microsoft.com/library/d...localization_using_the__net_framework_sdk.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconlocalization.asp

http://msdn.microsoft.com/library/d...conInternationalApplicationsInVisualBasic.asp

Hope this helps
Jay
 
J

Jay B. Harlow [MVP - Outlook]

Dennis,
I should add that some countries (such as Switzerland) actually support
multiple cultures (the country has 3 official languages!).

For example:
de-CH = German - Switzerland
fr-CH = French - Switzerland
it-CH = Italian - Switzerland

So localizing your app for Switzerland might actually entail translating it
into possible 3 languages...

NOTE: doing a quick google, shows that parts of Switzerland also speak
Romansh, however I don't see that listed as a valid .NET CultureInfo
class...

Hope this helps
Jay
 
C

Cor Ligthert

Jay,
I should add that some countries (such as Switzerland) actually support
multiple cultures (the country has 3 official languages!).

Just for the record 3 are supported as localisation however the country has
4 official languages.

There is as well Raeto-Roman (A real official and used language).

To give a in my opinion better example in this, Belgium has 3 official
languages with 2 supported languages what would mean that they have to use
nl-BE
fr-BE
de-De or de-Lu

It is in your links however now I am busy as well to let others not
misunderstood ( I know that you know this), the languages are in the OS
version, in the Framework version or in the RESX. It is not enough to set
the localization to get different languages.

By the way, is Spanish an official language in the US or only an spoken
language, I did not see a
sp-US

:)

Cor
 
N

Nak

Hi Cor,
It is in your links however now I am busy as well to let others not
misunderstood ( I know that you know this), the languages are in the OS
version, in the Framework version or in the RESX. It is not enough to set
the localization to get different languages.

How comes? I've tested it using standard controls on forms and it seems
to work fine just flupping between different cultures, or are you referring
to string lierals and the like that would need to be created by getting the
correct string from the resource file? If you could help me on this I would
be most appreciative as I need to get this localisation right to prevent a
tonne of work at a later date! Cheers Cor!

Nick.
 
C

Cor Ligthert

Nick

What cultures languages you want to do, there in England they have only one
language and one culture I thought,

Cor
 
G

Guest

Thanks Jay. I now understand what it's for and I'll do a bit more research
on how to use it. I guess if you want localized Forms, you have to create a
form for each languate you need it for then at start-up of your application,
the appropriate Form is loaded dependent on some type of CulturalInfo
setting. This setting would then also be used when you create a
resourcemanager to get different exceptions and other text.
 
J

Jay B. Harlow [MVP - Outlook]

Dennis,
No, you create a single form (MainForm for example). Then you localize this
single form.

When you localize it, VS.NET will create a .resx file each culture that you
localize it to, plus a "neutral" culture. The "neutral" culture is the
culture that you originally designed in the form in. The "neutral" culture
is what will be displayed if one of the specific cultures does not override
that property. For all my forms use en-US for the "neutral" language, as
that is the culture I am most familiar with.

When you start the form the system sets different properties of MainForm
based on the CurrentUICulture, it will look for the specific culture first
(de-CH), it will then look for the parent culture (de), finally it looks for
the neutral culture (the culture the form was originally designed in).

Continuing my Switzerland example:

If you use "Project - View All Files" you will see something like the
following:

MainForm.vb
MainForm.resx
MainForm.de-CH.resx
MainForm.fr-CH.resx
MainForm.it-CH.resx

The .vb has all the code for your MainForm. The first .resx file contains
the resources (property settings) for the "neutral" culture. The other three
..resx files contains resources (property settings) specific to those
cultures. If I was target most/all of Europe I would probably include de,
de-CH, de-DE, and de-AT for example. Where the MainForm.de.resx file
contains resource (property settings) used in German as a whole, then de-CH
would include only Switzerland German specific information...

In other words only the property settings for each language are created, not
a separate form for language...

Hope this helps
Jay
 
C

Cor Ligthert

Nick,

I tried it yesterday however was not anymore in the mood to write.
I have created a form
Put one label on it.
Set the localization to true
Have set the language to Dutch and wrote "Bier" in it
Have set the language to English and wrote "Beer" in it
I have inheritted this form
I have put an extra label on it
Have set the language to Dutch and wrote "Jenever" in it
Have set the language to Englis and wrote "Whiskey" in it
I have set the startup form to the inheritted form
I have runned it and it showed Bier and Jenever
Now I have put in the sub new (direct after the mybase.new) of the
inherrited form
Threading.Thread.CurrentThread.CurrentUICulture = New
Globalization.CultureInfo("en-US")
Than I see something strange because it gives Bier and Whiskey

I find this with the RESX a terrible system it seems for me if it is made by
people who never had anything to do with more languages.

There should be in my opinion one file for a complete project and not for
every form class in my opinion. I can only think when I do something with it
at WILLIAM J. LEDERER AND EUGENE BURDICK who describe it in a fantastic way.
http://www.wwnorton.com/catalog/fall98/uglyamerican.htm

To give you more information. Both the Original and the inherited form have
now four RESX files
en
nl
nl-NL
the default one.

I hope this gives you some ideas

This languages problem can in my opinion very good be done by an External
XML file where localized people write the correct text. Even when people
from Globalize countries write text in another language in a program, than
you see often strange things.

Even Microsoft has no versions for there programs which work all over the
world. They have versions for every language and some products even very
limited.
(Although before I give them ideas, I and probably all people from Globalize
countries would not like a version of VSNET in their special language. The
reason, the documentation is than often very flaw and than you would have to
translate words as Bier to Beer to find documentation. The last word I know
in many languages, however there are as well words, which are translated by
people who don't know the meaning and than I never, find the documentation)


Cor
 
N

Nak

Hi Cor,
I tried it yesterday however was not anymore in the mood to write.

LOL, I know the feeling, after spending most of the morning getting
grief from the I.R I feel like that!
I have created a form
Put one label on it.
Set the localization to true
Have set the language to Dutch and wrote "Bier" in it
Have set the language to English and wrote "Beer" in it
I have inheritted this form
I have put an extra label on it
Have set the language to Dutch and wrote "Jenever" in it
Have set the language to Englis and wrote "Whiskey" in it
I have set the startup form to the inheritted form
I have runned it and it showed Bier and Jenever
Now I have put in the sub new (direct after the mybase.new) of the
inherrited form
Threading.Thread.CurrentThread.CurrentUICulture = New
Globalization.CultureInfo("en-US")
Than I see something strange because it gives Bier and Whiskey

Mines working in a slightly different way, my base form has no
localisation, I didn't feel this was necessary as I'm only using derived
instances of it anyway, hence making the controls I want to localise as
Protected. I thought that would be quite a strange issue having to set the
language in the base *and* derived forms independently, there seems to be
allot of scope for error, though this is the first time I've needed
localisation so I could be very wrong.
I find this with the RESX a terrible system it seems for me if it is made
by people who never had anything to do with more languages.

Yes I agree, I have the benefit that I'm not going to be the one making
the necessary "foreign" localised resources so all I have to assure is that
when a different culture is selected it will be applied correctly.
There should be in my opinion one file for a complete project and not for
every form class in my opinion. I can only think when I do something with
it at WILLIAM J. LEDERER AND EUGENE BURDICK who describe it in a fantastic
way. http://www.wwnorton.com/catalog/fall98/uglyamerican.htm

That does sound like a good idea and I believe 3rd party solutions can
offer this can't they? I don't like relying on the IDE for too much, as
it's let me down in the past many a times, as I'm sure it has most people.
To give you more information. Both the Original and the inherited form
have now four RESX files
en
nl
nl-NL
the default one.

Yeah, lots of files, I have a default and en one now for my localised
forms, presumably when the resource assembly is made with the other cultures
in and placed in the bin directory in the necessary folder it will find
everything and all will be well?

bin\en\...
bin\nl-NL\...

Cheers for your help Cor, much appreciated!

Nick.
 
N

Nak

Hi Cor,
What cultures languages you want to do, there in England they have only
one language and one culture I thought,

LOL, that's quite funny actually, considering the diversity of the
English language in Great Britain alone, but then again this is all
AmericaniZed and seeing "English - United States" makes slightly itchy...

At the moment I'm not sure what languages it is being aimed at,
presumably the major European languages like, French, Spanish and German.

Nick.

Dim English as New Colour
Dim Americanize as New Color
 
C

Cor Ligthert

At the moment I'm not sure what languages it is being aimed at,
presumably the major European languages like, French, Spanish and German.
You don't get any answer anymore from me

:)

It is even wrong in the EU it is
German (Germany, Austria, Italia, Luxemburg, Lichtenstein) and also in
Switserland
Than probably French (France, Belgia, Monaco) and also in Switserland
Than probably English (UK, Ierland, Malta)
Than probably Italian (Italia) and also in Switserland
Than Polish
Than Spanish
Than Dutch(Netherlands and Belgia)

While in Europe Russian is the major language.

Cor
 
N

Nak

Hi Cor,
You don't get any answer anymore from me

Woops!, I did mean most commonly spoken, not quality of nation, or I
would never have said France... ;-)
It is even wrong in the EU it is
German (Germany, Austria, Italia, Luxemburg, Lichtenstein) and also in
Switserland
Than probably French (France, Belgia, Monaco) and also in Switserland
Than probably English (UK, Ierland, Malta)
Than probably Italian (Italia) and also in Switserland
Than Polish
Than Spanish
Than Dutch(Netherlands and Belgia)

While in Europe Russian is the major language.

Hmm, I understand where you are coming from but I do believe that
English is the most spoken language, correct me if I'm wrong but you more
than likely to find English speaking people in most countries. I know
Russia is much larger, but it's one of those things.

I think the choice of languages is going to be dependant on marketing
choices so that is why I said the languages that I did. No offence meant
anyway.

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top