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.
 
 
 

36 lines
788 B

  1. using System;
  2. using System.Globalization;
  3. namespace CIG.Translation
  4. {
  5. public class RawFloatString : ILocalizedString
  6. {
  7. public RawFloatString(float f, int decimals, bool showTrailingZeroes)
  8. {
  9. this._float = f;
  10. this._format = ((!showTrailingZeroes) ? ("0." + new string('#', decimals)) : ("N" + ((decimals < 0) ? string.Empty : decimals.ToString(CultureInfo.InvariantCulture))));
  11. }
  12. public override string ToString()
  13. {
  14. return string.Concat(new string[]
  15. {
  16. "[FloatString=",
  17. this._float.ToString(),
  18. ",Format=",
  19. this._format,
  20. "]"
  21. });
  22. }
  23. public string Translate()
  24. {
  25. return this._float.ToString(this._format, Localization.CurrentCulture.Info);
  26. }
  27. private float _float;
  28. private string _format;
  29. }
  30. }