View difference between Paste ID: L0YNxyfK and UJXM754g
SHOW: | | - or go back to the newest paste.
1
 public static class UserMessage
2
    {
3
        private static ResourceManager _resourceManager;
4
5
        static UserMessage()
6
        {
7
            string baseName = Assembly.GetAssembly(typeof(UserMessage)).GetName().Name + ".Messages.de";
8
            Console.WriteLine(baseName);
9
            _resourceManager = new ResourceManager(baseName, Properties.GlobalizationAssembly);
10
        }
11
12
        public static string GetMessage(string msgID, params string[] arguments)
13
        {
14
            string msg = "";
15
            string error = "[Message Error] cannot read Message " + msgID;
16
            try
17
            {
18
                //DefaultLanguage = 'de'
19
                //using the GetString overload with or without CultureInfo paramter makes no difference
20
                msg = _resourceManager.GetString(msgID, new CultureInfo(Properties.DefaultLanguage));
21
22
                for (int i = 0; i < arguments.Length; i++)
23
                {
24
                    msg = msg.Replace("{" + i.ToString() + "}", arguments[i]);
25
                }
26
            }
27
            catch (Exception ex)
28
            {
29
                Console.WriteLine(error + "\r\n" + ex.ToString());
30
                return error;
31
            }
32
            return msg;
33
        }
34
    }