c# - Three layers of culture specific resource files -


i need way use third "layer" of culture specific resource file. can possibly done in way should be, , possibly hacked somehow. , long hack isn't big, it's okay! solution possible (if i'm approaching problem wrong, please tell better solution).

normally have default resource file, works fallback. on top of can have culture specific resource language. want 'theme' specific resource.

the thing have several sites different themes (horses, cars, rc-units, etc.), , when use string localized resource file if resource isn't translated in specific language yet, it'll fallback english default language. cool!

a problem example: have phrase "add horse" , "add car" , might seem same (when comes grammar) in english, yet that's not case in polish or romanian!

so i'm thinking should, if possible, having english file "add {0}", polish file equivalent sentence in polish, on top of "car" specific polish translation grammar suited word "car" , "horse" specific polish translation grammar suited word "horse".

the problem might not bad 2 or 3 themes in 2 or 3 languages. easy think make switch in code handling few cases. thing is, have 15 themes, in 6 different languages , expanding.

hoping neat hacks or knowledge of used exotic features!

thanks in advance

i'm not pointing out solution problem, have, however, concern string-formatting:

one problem example use of string.format translations.

the "add {0}" part will, in languages, requre different wordings depending on, inserted {0} part.

an example:

"add horse" will, translated danish, become "tilføj din hest" whereas "add donkey" translate "tilføj dit æsel". can see there difference: din/dit not translateable correctly "add {0}". same goes other languags such german.


edit: pseudo-answer like: add more strings each resx-file (with identifiers addyouritemhorse, addyouritemracecar , addyouritemdonkey) each of themes. or create resource file pagename.racecar.da-dk.resx resources racecar-theme in , on. then, based on area of code, theme , current culture, following:

dictionary<string, string> resourcedictionary = new dictionary<string, string>(); private void filldictionary(string path) {     using (resxresourcereader rxrr = new resxresourcereader(path))     {         foreach (dictionaryentry entry in rxrr)         {             //fill filldictionary         }     } } 

and access string in dictionary concatenating want string representing theme:

string theme = "racecar"; label testlabel = new label(); testlabel.text = resourcedictionary[addyouritem + theme]; 

alternatively can have resource-file pr. area, language , theme like: mainform.racecar.da-dk.resx , build path passed filldictionary this:

string languagecode = thread.currentthread.currentculture.name; string path = "mainform." + theme + "." + llanguagecode + ".resx"; 

and pass path filldictionary-method.

note above code not tested. have written here top of mind. should point in direction of possible (not optimal) solution.

you can read more resxresourcereader here: working .resx files programmatically


Comments

Popular posts from this blog

android - Invite new users for my app using app notifications facebook -

Need help in packaging app using TideSDK on Windows -

html - CSS: Combine Texture and Color -