i have c# application needs support multiple culture types. have resx file made each language, , changing culture type changes resx file i'm using. works great. have client doesn't labels i've used. in en-us culture, , i'd keep resx en-us unchanged , way of our clients, 1 particular client, there way change resource file while still being part of en-us? example, can make "en-us2" resx file or that, , point that? or there better way have multiple different resx files same language?
i had asked similar question same exact idea (here.) c# meant used single resources.resx culture out. have gathered of hunting around have 2 choices: put in 1 file (like workerswelcometext , employeewelcometext) or create multiple resx files , construct model handle them , return resource file need:
model (not necessary, practice):
namespace bot.models { public class dialog { internal static string name { get; set; } internal static string culture { get; set; } //returns rsource file name.culture.resx internal static string resourcefile { { return $"{system.appdomain.currentdomain.basedirectory}properties\\{name}. {culture}.resx"; } } } }
construct method retrieve resource file:
// can in-line, remember reset resex if change file internal static string getstrres(string resourcestr) { //gets resource file system.resources.resxresourceset resxset = new system.resources.resxresourceset(models.dialog.resourcefile); string response = resxset.getstring(resourcestr); return response; }
to set model params:
models.dialog.name = "worker"; models.dialog.culture = "en-us";
to consume model:
// returns content of string resource key, same resources.workertext await context.postasync(botutils.getstrres("res_key"));
Comments
Post a Comment