コード例 #1
0
 /// <summary>
 /// Translator.Translate(Properties.Resources.ResourceManager, nameof(Properties.Resources.SomeKey));
 /// This assumes that the resource is something like 'Value: {0}' i.e. having one format parameter.
 /// </summary>
 /// <typeparam name="T">The type of <paramref name="arg0"/> generic to avoid boxing</typeparam>
 /// <param name="key">The key in</param>
 /// <param name="culture">The culture.</param>
 /// <param name="arg0">The argument will be used as string.Format(format, <paramref name="arg0"/>)</param>
 /// <param name="errorHandling">Specifies how to handle errors.</param>
 /// <returns>The key translated to the <paramref name="culture"/></returns>
 public static string Translate <T>(string key, CultureInfo culture, T arg0, ErrorHandling errorHandling = ErrorHandling.Default)
 {
     return(Translator.Translate(ResourceManager, key, culture, arg0, errorHandling));
 }
コード例 #2
0
 /// <summary>
 /// Translator.Translate(Properties.Resources.ResourceManager, nameof(Properties.Resources.SomeKey));
 /// This assumes that the resource is something like 'Value: {0}' i.e. having one format parameter.
 /// </summary>
 /// <typeparam name="T0">The type of <paramref name="arg0"/> generic to avoid boxing</typeparam>
 /// <typeparam name="T1">The type of <paramref name="arg1"/> generic to avoid boxing</typeparam>
 /// <param name="key">The key.</param>
 /// <param name="arg0">The argument will be used as first arguyment in string.Format(culture, format, <paramref name="arg0"/>, <paramref name="arg1"/>)</param>
 /// <param name="arg1">The argument will be used as second argument string.Format(culture, format, <paramref name="arg0"/>, <paramref name="arg1"/>)</param>
 /// <param name="errorHandling">Specifies how to handle errors.</param>
 /// <returns>The key translated to the <see cref="Translator.CurrentCulture"/></returns>
 public static string Translate <T0, T1>(string key, T0 arg0, T1 arg1, ErrorHandling errorHandling = ErrorHandling.Default)
 {
     return(Translator.Translate(ResourceManager, key, Translator.CurrentCulture, arg0, arg1, errorHandling));
 }
コード例 #3
0
 /// <summary>
 /// Call like this Translator&lt;Properties.Resources&gt;.Translate(nameof(Properties.Resources.SomeKey));
 /// </summary>
 /// <param name="key">Path to the key. Must be included <typeparamref name="TResources"/>.</param>
 /// <param name="culture">The culture, if null CultureInfo.InvariantCulture is used</param>
 /// <param name="errorHandling">Specifies how errors are handled.</param>
 /// <returns>The key translated to the <paramref name="culture"/></returns>
 public static string Translate(string key, CultureInfo culture, ErrorHandling errorHandling)
 {
     return(Translator.Translate(ResourceManager, key, culture, errorHandling));
 }
コード例 #4
0
ファイル: Translation.cs プロジェクト: forki/Gu.Localization
 /// <inheritdoc />
 public string Translate(CultureInfo culture, ErrorHandling errorHandlingStrategy = ErrorHandling.Inherit)
 {
     return(Translator.Translate(this.resourceManager, this.Key, culture, errorHandlingStrategy));
 }