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

51 lines
1.1 KiB

  1. using System;
  2. namespace CIG.Translation
  3. {
  4. public class FormatString : ILocalizedString
  5. {
  6. public FormatString(ILocalizedString format, params ILocalizedString[] args)
  7. {
  8. if (format == null)
  9. {
  10. throw new ArgumentNullException("SUISS Localization: format");
  11. }
  12. this._format = format;
  13. this._args = ((args == null) ? new ILocalizedString[0] : args);
  14. }
  15. public override string ToString()
  16. {
  17. int num = this._args.Length;
  18. string[] array = new string[num];
  19. for (int i = 0; i < num; i++)
  20. {
  21. array[i] = this._args[i].ToString();
  22. }
  23. return string.Concat(new string[]
  24. {
  25. "[FormatString=",
  26. this._format.ToString(),
  27. ",Args=[",
  28. string.Join(";", array),
  29. "]]"
  30. });
  31. }
  32. public string Translate()
  33. {
  34. int num = this._args.Length;
  35. string[] array = new string[num];
  36. for (int i = 0; i < num; i++)
  37. {
  38. array[i] = this._args[i].Translate();
  39. }
  40. return string.Format(this._format.Translate(), array);
  41. }
  42. private ILocalizedString _format;
  43. private ILocalizedString[] _args;
  44. }
  45. }