@@ -43,6 +43,82 @@ public static class I18n
43
43
/// <param name="arguments">The values to format the string with.</param>
44
44
public static string ? T ( string name , bool returnKey , params object [ ] arguments ) => _i18n . T ( name , returnKey , arguments ) ;
45
45
46
+ /// <summary>
47
+ /// Gets the string resource with the given name.
48
+ /// </summary>
49
+ /// <param name="name">The name of the string resource.</param>
50
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
51
+ /// <returns></returns>
52
+ public static string T < TResource > ( string name )
53
+ => _serviceProvider . GetRequiredService < II18n < TResource > > ( ) . T ( name ) ;
54
+
55
+ /// <summary>
56
+ /// Gets the string resource with the given name.
57
+ /// </summary>
58
+ /// <param name="propertyExpression">attribute expression.</param>
59
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
60
+ /// <returns></returns>
61
+ public static string T < TResource > ( Expression < Func < TResource , string > > propertyExpression )
62
+ => T < TResource > ( ExpressionExtensions . GetI18nName ( propertyExpression ) ) ;
63
+
64
+ /// <summary>
65
+ /// Gets the string resource with the given name.
66
+ /// </summary>
67
+ /// <param name="name">The name of the string resource.</param>
68
+ /// <param name="returnKey">Return Key when key does not exist, default: true</param>
69
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
70
+ /// <returns></returns>
71
+ public static string ? T < TResource > ( string name , bool returnKey )
72
+ => _serviceProvider . GetRequiredService < II18n < TResource > > ( ) . T ( name , returnKey ) ;
73
+
74
+ /// <summary>
75
+ /// Gets the string resource with the given name.
76
+ /// </summary>
77
+ /// <param name="propertyExpression">attribute expression.</param>
78
+ /// <param name="returnKey">Return Key when key does not exist, default: true</param>
79
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
80
+ /// <returns></returns>
81
+ public static string ? T < TResource > ( Expression < Func < TResource , string > > propertyExpression , bool returnKey )
82
+ => T < TResource > ( ExpressionExtensions . GetI18nName ( propertyExpression ) , returnKey ) ;
83
+
84
+ /// <summary>
85
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
86
+ /// </summary>
87
+ /// <param name="name">The name of the string resource.</param>
88
+ /// <param name="arguments">The values to format the string with.</param>
89
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
90
+ public static string T < TResource > ( string name , params object [ ] arguments )
91
+ => _serviceProvider . GetRequiredService < II18n < TResource > > ( ) . T ( name , arguments ) ;
92
+
93
+ /// <summary>
94
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
95
+ /// </summary>>
96
+ /// <param name="propertyExpression">attribute expression.</param>
97
+ /// <param name="arguments">The values to format the string with.</param>
98
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
99
+ public static string T < TResource > ( Expression < Func < TResource , string > > propertyExpression , params object [ ] arguments )
100
+ => T < TResource > ( ExpressionExtensions . GetI18nName ( propertyExpression ) , arguments ) ;
101
+
102
+ /// <summary>
103
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
104
+ /// </summary>
105
+ /// <param name="name">The name of the string resource.</param>
106
+ /// <param name="returnKey">Return Key when key does not exist, default: true</param>
107
+ /// <param name="arguments">The values to format the string with.</param>
108
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
109
+ public static string ? T < TResource > ( string name , bool returnKey , params object [ ] arguments )
110
+ => _serviceProvider . GetRequiredService < II18n < TResource > > ( ) . T ( name , returnKey , arguments ) ;
111
+
112
+ /// <summary>
113
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
114
+ /// </summary>
115
+ /// <param name="propertyExpression">attribute expression.</param>
116
+ /// <param name="returnKey">Return Key when key does not exist, default: true</param>
117
+ /// <param name="arguments">The values to format the string with.</param>
118
+ /// <typeparam name="TResource">Customer Resource Type</typeparam>
119
+ public static string ? T < TResource > ( Expression < Func < TResource , string > > propertyExpression , bool returnKey , params object [ ] arguments )
120
+ => T < TResource > ( ExpressionExtensions . GetI18nName ( propertyExpression ) , returnKey , arguments ) ;
121
+
46
122
public static CultureInfo GetCultureInfo ( ) => _i18n . GetCultureInfo ( ) ;
47
123
48
124
/// <summary>
0 commit comments