PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Gettext.CsUtils/Core/Gettext.Cs/Templates/Strings.cs

https://code.google.com/p/gettext-cs-utils/
C# | 166 lines | 89 code | 22 blank | 55 comment | 7 complexity | ac789e1855c2834dc1bde50226c07143 MD5 | raw file
  1. /**
  2. * gettext-cs-utils
  3. *
  4. * Copyright 2011 Manas Technology Solutions
  5. * http://www.manas.com.ar/
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. **/
  21. // <autogenerated>
  22. // This code was generated by a tool. Any changes made manually will be lost
  23. // the next time this code is regenerated.
  24. // </autogenerated>
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Linq;
  28. using System.Text;
  29. using System.Globalization;
  30. using System.Threading;
  31. using System.Configuration;
  32. using System.Diagnostics;
  33. using System.IO;
  34. using System.Reflection;
  35. namespace Gettext
  36. {
  37. public class Strings
  38. {
  39. private static Object resourceManLock = new Object();
  40. private static System.Resources.ResourceManager resourceMan;
  41. private static System.Globalization.CultureInfo resourceCulture;
  42. public const string ResourceName = "Strings";
  43. private static string resourcesDir = GetSetting("ResourcesDir", "Po");
  44. private static string fileFormat = GetSetting("ResourcesFileFormat", "{{culture}}/{{resource}}.po");
  45. private static string GetSetting(string setting, string defaultValue)
  46. {
  47. var section = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
  48. if (section == null) return defaultValue;
  49. else return section[setting] ?? defaultValue;
  50. }
  51. /// <summary>
  52. /// Resources directory used to retrieve files from.
  53. /// </summary>
  54. public static string ResourcesDirectory
  55. {
  56. get { return resourcesDir; }
  57. set { resourcesDir = value; }
  58. }
  59. /// <summary>
  60. /// Format of the file based on culture and resource name.
  61. /// </summary>
  62. public static string FileFormat
  63. {
  64. get { return fileFormat; }
  65. set { fileFormat = value; }
  66. }
  67. /// <summary>
  68. /// Returns the cached ResourceManager instance used by this class.
  69. /// </summary>
  70. public static System.Resources.ResourceManager ResourceManager
  71. {
  72. get
  73. {
  74. if (object.ReferenceEquals(resourceMan, null))
  75. {
  76. lock (resourceManLock)
  77. {
  78. if (object.ReferenceEquals(resourceMan, null))
  79. {
  80. var directory = resourcesDir;
  81. var mgr = new global::Gettext.Cs.GettextResourceManager(ResourceName, directory, fileFormat);
  82. resourceMan = mgr;
  83. }
  84. }
  85. }
  86. return resourceMan;
  87. }
  88. }
  89. /// <summary>
  90. /// Overrides the current thread's CurrentUICulture property for all
  91. /// resource lookups using this strongly typed resource class.
  92. /// </summary>
  93. public static System.Globalization.CultureInfo Culture
  94. {
  95. get { return resourceCulture; }
  96. set { resourceCulture = value; }
  97. }
  98. /// <summary>
  99. /// Looks up a localized string; used to mark string for translation as well.
  100. /// </summary>
  101. public static string T(string t)
  102. {
  103. return T(null, t);
  104. }
  105. /// <summary>
  106. /// Looks up a localized string; used to mark string for translation as well.
  107. /// </summary>
  108. public static string T(CultureInfo info, string t)
  109. {
  110. if (String.IsNullOrEmpty(t)) return t;
  111. var translated = ResourceManager.GetString(t, info ?? resourceCulture);
  112. return String.IsNullOrEmpty(translated) ? t : translated;
  113. }
  114. /// <summary>
  115. /// Looks up a localized string and formats it with the parameters provided; used to mark string for translation as well.
  116. /// </summary>
  117. public static string T(string t, params object[] parameters)
  118. {
  119. return T(null, t, parameters);
  120. }
  121. /// <summary>
  122. /// Looks up a localized string and formats it with the parameters provided; used to mark string for translation as well.
  123. /// </summary>
  124. public static string T(CultureInfo info, string t, params object[] parameters)
  125. {
  126. if (String.IsNullOrEmpty(t)) return t;
  127. return String.Format(T(info, t), parameters);
  128. }
  129. /// <summary>
  130. /// Marks a string for future translation, does not translate it now.
  131. /// </summary>
  132. public static string M(string t)
  133. {
  134. return t;
  135. }
  136. /// <summary>
  137. /// Returns the resource set available for the specified culture.
  138. /// </summary>
  139. public static System.Resources.ResourceSet GetResourceSet(CultureInfo culture)
  140. {
  141. return ResourceManager.GetResourceSet(culture, true, true);
  142. }
  143. }
  144. }