Пример #1
0
 /// <summary>
 /// Create an instance of `MessageContext`.
 ///
 /// The `locales` argument is used to instantiate `Intl` formatters used by
 /// translations.  The `options` object can be used to configure the context.
 ///
 /// Examples:
 ///
 ///     const ctx = new MessageContext(locales);
 ///
 ///     const ctx = new MessageContext(locales, { useIsolating: false });
 ///
 ///     const ctx = new MessageContext(locales, {
 ///       useIsolating: true,
 ///       functions: {
 ///         NODE_ENV: () => process.env.NODE_ENV
 ///       }
 ///     });
 ///
 /// Available options:
 ///
 ///   - `functions` - an object of additional functions available to
 ///                   translations as builtins.
 ///
 ///   - `useIsolating` - boolean specifying whether to use Unicode isolation
 ///                    marks (FSI, PDI) for bidi interpolations.
 ///
 ///   - `transform` - a function used to transform string parts of patterns.
 /// </summary>
 /// <param name="locales">Locale or locales of the context</param>
 /// <param name="options">[options]</param>
 ///
 public MessageContext(
     IEnumerable <string> locales,
     MessageContextOptions options = null
     )
 {
     Locales = locales;
     Culture = new CultureInfo(Locales.First());
     if (options != null)
     {
         UseIsolating = options.UseIsolating;
     }
     Transform = options?.Transform ?? NoOpTransform;
     Functions = options?.Functions ?? s_emptyFunctions;
 }
Пример #2
0
 public MessageContext(
     string locale,
     MessageContextOptions options = null
     ) : this(new string[] { locale }, options)
 {
 }