Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class UserMessage
- {
- private static ResourceManager _resourceManager;
- static UserMessage()
- {
- string baseName = Assembly.GetAssembly(typeof(UserMessage)).GetName().Name + ".Messages.de";
- Console.WriteLine(baseName);
- _resourceManager = new ResourceManager(baseName, Properties.GlobalizationAssembly);
- }
- public static string GetMessage(string msgID, params string[] arguments)
- {
- string msg = "";
- string error = "[Message Error] cannot read Message " + msgID;
- try
- {
- //DefaultLanguage = 'de'
- //using the GetString overload with or without CultureInfo paramter makes no difference
- msg = _resourceManager.GetString(msgID, new CultureInfo(Properties.DefaultLanguage));
- for (int i = 0; i < arguments.Length; i++)
- {
- msg = msg.Replace("{" + i.ToString() + "}", arguments[i]);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(error + "\r\n" + ex.ToString());
- return error;
- }
- return msg;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement