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.2 kB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Shadowsocks.Properties;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. namespace Shadowsocks.Controller
  7. {
  8. public class I18N
  9. {
  10. protected static Dictionary<string, string> Strings;
  11. static I18N()
  12. {
  13. Strings = new Dictionary<string, string>();
  14. if (System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag.ToLowerInvariant().StartsWith("zh"))
  15. {
  16. string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n");
  17. foreach (string line in lines)
  18. {
  19. string[] kv = Regex.Split(line, "=");
  20. if (kv.Length == 2)
  21. {
  22. Strings[kv[0]] = kv[1];
  23. }
  24. }
  25. }
  26. }
  27. public static string GetString(string key)
  28. {
  29. if (Strings.ContainsKey(key))
  30. {
  31. return Strings[key];
  32. }
  33. else
  34. {
  35. return key;
  36. }
  37. }
  38. }
  39. }