vb.net - How to create a multilingual project -


i'm new vb.net , i'm trying simple multilingual project.

so far i've created 2 resource files:

en-us.resx   pt-pt.resx 

in both of them have same id's , diferent values (strings only) (these strings used across multiple forms)

when change laguage do:

thread.currentthread.currentculture = new cultureinfo("en-us") 

or

thread.currentthread.currentculture = new cultureinfo("pt-pt") 

based on language want see.

but dont know how access resource files properly, doing:

dim assembly system.reflection.assembly assembly = me.gettype.assembly dim resourcemanager new system.resources.resourcemanager("my.resources", assembly)   msgbox(resourcemanager.getstring("test"))   

gives me exception system.resources.missingmanifestresourceexception' occurred in mscorlib.dll

what missing?

edit after first sugestion: enter image description here

enter image description here

this example requires text-based resource files listed in following table. each has single string resource named datestart.

  culture    |     file name     |  resource name    |    resource value     en-us        datestrings.txt       datestart              today    pt-pt    datestrings.pt-pt.txt     datestart               hoje é 

this code uses getstring(string, cultureinfo) method retrieve culture-specific resources. example's default culture english (en), , includes satellite assemblies portuguese (portugal) (pt-pt) culture.

module example    public sub main()    thread.currentthread.currentculture = cultureinfo.createspecificculture("en-us")   thread.currentthread.currentuiculture = cultureinfo.createspecificculture("pt-pt")    dim culturenames() string = { "en-us", "pt-pt" }   dim rm new resourcemanager("datestrings",gettype(example).assembly)       'access resource file     each culturename in culturenames              dim culture cultureinfo = cultureinfo.createspecificculture(culturename)              dim datestring string = rm.getstring("datestart", culture)              console.writeline("{0}: {1} {2}.", culture.displayname, datestring,                                                  date.now.tostring("m", culture))                                         console.writeline()     next     end sub end module  

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -