You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

I18N.cs 1.3 kB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.IO;
  5. namespace Shadowsocks.Controller
  6. {
  7. using Shadowsocks.Properties;
  8. public class I18N
  9. {
  10. protected static Dictionary<string, string> Strings;
  11. static I18N()
  12. {
  13. Strings = new Dictionary<string, string>();
  14. if (CultureInfo.CurrentCulture.IetfLanguageTag.StartsWith("zh", StringComparison.OrdinalIgnoreCase))
  15. {
  16. using (var sr = new StringReader(Resources.cn))
  17. {
  18. foreach (var line in sr.NonWhiteSpaceLines())
  19. {
  20. if (line[0] == '#')
  21. continue;
  22. var pos = line.IndexOf('=');
  23. if (pos < 1)
  24. continue;
  25. Strings[line.Substring(0, pos)] = line.Substring(pos + 1);
  26. }
  27. }
  28. }
  29. }
  30. public static string GetString(string key)
  31. {
  32. if (Strings.ContainsKey(key))
  33. {
  34. return Strings[key];
  35. }
  36. else
  37. {
  38. return key;
  39. }
  40. }
  41. }
  42. }