How to get available language resources

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

Hello,

I use vs2005 and I try to find out how I can get a list of the cultures
where I have made resources for.

So I can make a combobox where I can choose the language I want to use.

With CultureInfo.GetCultures I became a complete list, but how can I filter
only the Cultures I need?

Thanks
Gerrit
 
Gerrit,

You need to create a type that derives from ResourceManager. Then,
create an instance of your ResourceManager for the appropriate assembly. In
your derived class, you can then expose the keys to the Hashtable stored in
the ResourceSets field of the ResourceManager (it is marked as protected, so
it will be available to you).
 
Nicholas,

Thanks for your answer. But I don't know how to do it. Can you give me some
hints?

I have sometihing like this, but that doesn't work..

public class MyClass
{
public void FillLanguagesComboBox()
{
MyManager manager = new MyManager();
manager.GetHashCode();
}
}

public class MyManager : ResourceManager
{

}

Thanks, Gerrit

Nicholas Paldino said:
Gerrit,

You need to create a type that derives from ResourceManager. Then,
create an instance of your ResourceManager for the appropriate assembly.
In your derived class, you can then expose the keys to the Hashtable
stored in the ResourceSets field of the ResourceManager (it is marked as
protected, so it will be available to you).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

GS said:
Hello,

I use vs2005 and I try to find out how I can get a list of the cultures
where I have made resources for.

So I can make a combobox where I can choose the language I want to use.

With CultureInfo.GetCultures I became a complete list, but how can I
filter only the Cultures I need?

Thanks
Gerrit
 
GS,

You need to access the ResourceSets Hashtable instance exposed by the
ResourceManager class in your MyManager class. So basically, you would do
something like this:

public class MyManager : ResourceManager
{
public Hashtable GetResourceSets()
{
return ResourceSets;
}
}

You really shouldn't do it like that, as it exposes the internal
hashtable for that resource manager, which makes it open to being changed
(you should get the keys from the hashtable and expose those).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

GS said:
Nicholas,

Thanks for your answer. But I don't know how to do it. Can you give me
some hints?

I have sometihing like this, but that doesn't work..

public class MyClass
{
public void FillLanguagesComboBox()
{
MyManager manager = new MyManager();
manager.GetHashCode();
}
}

public class MyManager : ResourceManager
{

}

Thanks, Gerrit

Nicholas Paldino said:
Gerrit,

You need to create a type that derives from ResourceManager. Then,
create an instance of your ResourceManager for the appropriate assembly.
In your derived class, you can then expose the keys to the Hashtable
stored in the ResourceSets field of the ResourceManager (it is marked as
protected, so it will be available to you).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

GS said:
Hello,

I use vs2005 and I try to find out how I can get a list of the cultures
where I have made resources for.

So I can make a combobox where I can choose the language I want to use.

With CultureInfo.GetCultures I became a complete list, but how can I
filter only the Cultures I need?

Thanks
Gerrit
 
Unforunately is is not working, or I can not get it working.

But isn't it so that ResourceSets gets the available strings etc of the
loaded Resource / CultureInfo and not a list of the available translations?

Thanks, Gerrit

--

www.gsnel.nl
Nicholas Paldino said:
GS,

You need to access the ResourceSets Hashtable instance exposed by the
ResourceManager class in your MyManager class. So basically, you would do
something like this:

public class MyManager : ResourceManager
{
public Hashtable GetResourceSets()
{
return ResourceSets;
}
}

You really shouldn't do it like that, as it exposes the internal
hashtable for that resource manager, which makes it open to being changed
(you should get the keys from the hashtable and expose those).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

GS said:
Nicholas,

Thanks for your answer. But I don't know how to do it. Can you give me
some hints?

I have sometihing like this, but that doesn't work..

public class MyClass
{
public void FillLanguagesComboBox()
{
MyManager manager = new MyManager();
manager.GetHashCode();
}
}

public class MyManager : ResourceManager
{

}

Thanks, Gerrit

"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
schreef in bericht
Gerrit,

You need to create a type that derives from ResourceManager. Then,
create an instance of your ResourceManager for the appropriate assembly.
In your derived class, you can then expose the keys to the Hashtable
stored in the ResourceSets field of the ResourceManager (it is marked as
protected, so it will be available to you).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello,

I use vs2005 and I try to find out how I can get a list of the cultures
where I have made resources for.

So I can make a combobox where I can choose the language I want to use.

With CultureInfo.GetCultures I became a complete list, but how can I
filter only the Cultures I need?

Thanks
Gerrit
 
Back
Top