1 <Type Name="Catalog" FullName="Mono.Unix.Catalog">
2 <TypeSignature Language="C#" Value="public class Catalog" />
3 <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Catalog extends System.Object" />
5 <AssemblyName>Mono.Posix</AssemblyName>
6 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
7 <AssemblyVersion>2.0.0.0</AssemblyVersion>
8 <AssemblyVersion>4.0.0.0</AssemblyVersion>
10 <ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
12 <BaseTypeName>System.Object</BaseTypeName>
16 <summary>A wrapper to the <c>libintl</c> library providing message translation capabilities.</summary>
19 <para>The following example demonstrates the use of the
20 <see cref="T:Mono.Unix.Catalog" /> type. See also:
21 http://www.mono-project.com/Internationalization.</para>
22 <code lang="C#">// File: i18n.cs
28 public static void Main(string[] argv)
30 Catalog.Init ("i18n", "./locale");
31 Console.WriteLine (Catalog.GetString ("My name is") + " Enzo");
33 Console.WriteLine (Catalog.GetPluralString ("I'm {0} year old.",
34 "I'm {0} years old.", i), i);
38 <para>To generate the translations, use:</para>
39 <code lang="sh">xgettext --from-code=UTF-8 i18n.cs -o es.po</code>
40 <para>Edit the translations in <c>es.po</c>, then compile the
41 translations and copy the file so that <c>libintl</c> can find
43 <code lang="sh">mkdir -p locale/es/LC_MESSAGES/
44 msgfmt es.po -o locale/es/LC_MESSAGES/i18n.mo</code>
45 <para>To run your example with the new translations:</para>
46 <code lang="sh">LANGUAGE=es mono i18n.exe</code>
51 <Member MemberName="GetPluralString">
52 <MemberSignature Language="C#" Value="public static string GetPluralString (string s, string p, int n);" />
53 <MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetPluralString(string s, string p, int32 n) cil managed" />
54 <MemberType>Method</MemberType>
56 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
57 <AssemblyVersion>2.0.0.0</AssemblyVersion>
58 <AssemblyVersion>4.0.0.0</AssemblyVersion>
61 <ReturnType>System.String</ReturnType>
64 <Parameter Name="s" Type="System.String" />
65 <Parameter Name="p" Type="System.String" />
66 <Parameter Name="n" Type="System.Int32" />
69 <param name="s">A <see cref="T:System.String" /> containing the singular form of the string. It is also used as the key to search the catalog on.</param>
70 <param name="p">A <see cref="T:System.String" /> containing the plural form of the string.</param>
72 An <see cref="T:System.Int32" /> containing a number that determines
73 which form of the string to return.
74 If <paramref name="n" /> is one, the translation for
75 <paramref name="s" /> is returned; otherwise, the translation for
76 <paramref name="p" /> is returned.
78 <summary>Returns a native language translation of a text whose form depends on the number passed to the method.</summary>
79 <returns>The translated string. If no message catalog can be found, the method returns the singular form if <paramref name="n" /> == 1, the plural form otherwise.</returns>
82 <para>The following example demonstrates the use of the
83 <see cref="T:Mono.Unix.Catalog" /> type. See also:
84 http://www.mono-project.com/Internationalization.</para>
85 <code lang="C#">// File: i18n.cs
91 public static void Main(string[] argv)
93 Catalog.Init ("i18n", "./locale");
94 Console.WriteLine (Catalog.GetString ("My name is") + " Enzo");
96 Console.WriteLine (Catalog.GetPluralString ("I'm {0} year old.",
97 "I'm {0} years old.", i), i);
105 <Member MemberName="GetString">
106 <MemberSignature Language="C#" Value="public static string GetString (string s);" />
107 <MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetString(string s) cil managed" />
108 <MemberType>Method</MemberType>
110 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
111 <AssemblyVersion>2.0.0.0</AssemblyVersion>
112 <AssemblyVersion>4.0.0.0</AssemblyVersion>
115 <ReturnType>System.String</ReturnType>
118 <Parameter Name="s" Type="System.String" />
121 <param name="s">A <see cref="T:System.String" /> containing the text to be translated. It is used as the key to search the catalog on.</param>
122 <summary>Returns a native language translation of the text passed as the parameter.</summary>
123 <returns>The translated string, if found in the catalog, <paramref name="s" /> otherwise.</returns>
126 <para>The following example demonstrates the use of the
127 <see cref="T:Mono.Unix.Catalog" /> type. See also:
128 http://www.mono-project.com/Internationalization.</para>
129 <code lang="C#">// File: i18n.cs
135 public static void Main(string[] argv)
137 Catalog.Init ("i18n", "./locale");
138 Console.WriteLine (Catalog.GetString ("My name is") + " Enzo");
140 Console.WriteLine (Catalog.GetPluralString ("I'm {0} year old.",
141 "I'm {0} years old.", i), i);
149 <Member MemberName="Init">
150 <MemberSignature Language="C#" Value="public static void Init (string package, string localedir);" />
151 <MemberSignature Language="ILAsm" Value=".method public static hidebysig void Init(string package, string localedir) cil managed" />
152 <MemberType>Method</MemberType>
154 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
155 <AssemblyVersion>2.0.0.0</AssemblyVersion>
156 <AssemblyVersion>4.0.0.0</AssemblyVersion>
159 <ReturnType>System.Void</ReturnType>
162 <Parameter Name="package" Type="System.String" />
163 <Parameter Name="localedir" Type="System.String" />
166 <param name="package">A <see cref="T:System.String" /> containing the name of the package (domain) that is to be accessed.</param>
167 <param name="localedir">A <see cref="T:System.String" /> containing the top level directory (folder) under which the message catalog(s) are stored.</param>
168 <summary>Initialize the object instance by providing information required to build the base directory where the message catalog is stored.</summary>
169 <remarks>The path to the message catalogs is constructed as follows <c>localedir/locale/category/package</c>. In this notation <c>locale</c> and <c>category</c> are, respectively, the locale name and the message category name, such as <c>LC_MESSAGES</c>. The object is initialized so that it translates the strings retrieved from the on-disk catalog into the UTF-8 encoding.