예제 #1
0
        /**
         * {@icu} Creates a UResourceBundle for the specified locale and specified base name,
         * from which users can extract resources by using their corresponding keys.
         * @param baseName string containing the name of the data package.
         *                    If null the default ICU package name is used.
         * @param locale  specifies the locale for which we want to open the resource.
         *                If null the bundle for default locale is opened.
         * @param loader  the loader to use
         * @return a resource bundle for the given base name and locale
         * @stable ICU 3.8
         */
        public static UResourceBundle GetBundleInstance(string baseName, CultureInfo locale,
                                                        Assembly loader)
        {
            if (baseName == null)
            {
                baseName = ICUData.ICU_BASE_NAME;
            }
            ULocale uloc = locale == null?ULocale.GetDefault() : ULocale.ForLocale(locale);

            return(GetBundleInstance(baseName, uloc.GetBaseName(), loader, false));
        }
예제 #2
0
        /**
         * {@icu} Creates a UResourceBundle for the specified locale and specified base name,
         * from which users can extract resources by using their corresponding keys.
         * @param baseName string containing the name of the data package.
         *                    If null the default ICU package name is used.
         * @param locale  specifies the locale for which we want to open the resource.
         *                If null the bundle for default locale is opened.
         * @return a resource bundle for the given base name and locale
         * @stable ICU 3.0
         */

        public static UResourceBundle GetBundleInstance(string baseName, CultureInfo locale)
        {
            if (baseName == null)
            {
                baseName = ICUData.ICU_BASE_NAME;
            }
            ULocale uloc = locale == null?ULocale.GetDefault() : ULocale.ForLocale(locale);

            //return GetBundleInstance(baseName, uloc.GetBaseName(),
            //                         ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
            return(GetBundleInstance(baseName, uloc.GetBaseName(),
                                     GetAssembly(baseName), false));
        }
예제 #3
0
 /// <summary>
 /// Returns the default numbering system for the specified locale.
 /// </summary>
 /// <stable>ICU 4.2</stable>
 public static NumberingSystem GetInstance(CultureInfo inLocale)
 {
     return(GetInstance(ULocale.ForLocale(inLocale)));
 }
 public Builder(CultureInfo loc)
     : this(ULocale.ForLocale(loc))
 {
 }
예제 #5
0
 public override string LocaleDisplayName(CultureInfo locale)
 {
     return(LocaleDisplayNameInternal(ULocale.ForLocale(locale)));
 }
예제 #6
0
 /// <summary>
 /// Creates a new cardinal-number <see cref="PluralFormat"/> for a given set of rules.
 /// The standard number formatting will be done using the given locale.
 /// </summary>
 /// <param name="locale">the default number formatting will be done using this
 /// locale.</param>
 /// <param name="rules">defines the behavior of the <see cref="PluralFormat"/>
 /// object.</param>
 /// <stable>ICU 54</stable>
 public PluralFormat(CultureInfo locale, PluralRules rules)
     : this(ULocale.ForLocale(locale), rules)
 {
 }
예제 #7
0
 /// <summary>
 /// Creates a new <see cref="PluralFormat"/> for the plural type.
 /// The standard number formatting will be done using the given <see cref="CultureInfo"/>.
 /// </summary>
 /// <param name="locale">the default number formatting will be done using this
 /// locale.</param>
 /// <param name="type">The plural type (e.g., cardinal or ordinal).</param>
 /// <stable>ICU 54</stable>
 public PluralFormat(CultureInfo locale, PluralType type)
     : this(ULocale.ForLocale(locale), type)
 {
 }
예제 #8
0
 /// <summary>
 /// Return an instance of CurrencyDisplayNames that provides information
 /// localized for display in the provided locale.  If noSubstitute is false,
 /// this behaves like <see cref="GetInstance(CultureInfo)"/>.  Otherwise, 1) if there
 /// is no supporting data for the locale at all, there is no fallback through
 /// the default locale or root, and null is returned, and 2) if there is data
 /// for the locale, but not data for the requested ISO code, null is returned
 /// from those APIs instead of a substitute value.
 /// </summary>
 /// <param name="locale">The <see cref="CultureInfo"/> into which to localize the names.</param>
 /// <param name="noSubstitute">If true, do not return substitute values.</param>
 /// <returns>A <see cref="CurrencyDisplayNames"/>.</returns>
 /// <stable>ICU 54</stable>
 public static CurrencyDisplayNames GetInstance(CultureInfo locale, bool noSubstitute)
 {
     return(GetInstance(ULocale.ForLocale(locale), noSubstitute));
 }
예제 #9
0
 /// <summary>
 /// Creates a new cardinal-number <see cref="PluralFormat"/> for a given
 /// <see cref="CultureInfo"/>.
 /// </summary>
 /// <param name="locale">the <see cref="PluralFormat"/> will be configured with
 /// rules for this locale. This locale will also be used for standard
 /// number formatting.</param>
 /// <stable>ICU 54</stable>
 public PluralFormat(CultureInfo locale)
     : this(ULocale.ForLocale(locale))
 {
 }
예제 #10
0
        private static BreakIterator CreateBreakInstance(ULocale locale, int kind)
        {
            RuleBasedBreakIterator iter = null;
            ICUResourceBundle      rb   = ICUResourceBundle.
                                          GetBundleInstance(ICUData.ICU_BRKITR_BASE_NAME, locale,
                                                            ICUResourceBundle.OpenType.LOCALE_ROOT);

            //
            //  Get the binary rules.
            //
            ByteBuffer bytes      = null;
            string     typeKeyExt = null;

            if (kind == BreakIterator.KIND_LINE)
            {
                string lbKeyValue = locale.GetKeywordValue("lb");
                if (lbKeyValue != null && (lbKeyValue.Equals("strict") || lbKeyValue.Equals("normal") || lbKeyValue.Equals("loose")))
                {
                    typeKeyExt = "_" + lbKeyValue;
                }
            }

            try
            {
                string typeKey       = (typeKeyExt == null) ? KIND_NAMES[kind] : KIND_NAMES[kind] + typeKeyExt;
                string brkfname      = rb.GetStringWithFallback("boundaries/" + typeKey);
                string rulesFileName = ICUData.ICU_BRKITR_NAME + '/' + brkfname;
                bytes = ICUBinary.GetData(rulesFileName);
            }
            catch (Exception e)
            {
                throw new MissingManifestResourceException(e.ToString(), e /*, "", ""*/);
            }

            //
            // Create a normal RuleBasedBreakIterator.
            //
            try
            {
#pragma warning disable 612, 618
                iter = RuleBasedBreakIterator.GetInstanceFromCompiledRules(bytes);
#pragma warning restore 612, 618
            }
            catch (IOException e)
            {
                // Shouldn't be possible to get here.
                // If it happens, the compiled rules are probably corrupted in some way.
                Assert.Fail(e);
            }
            // TODO: Determine valid and actual locale correctly.
            ULocale uloc = ULocale.ForLocale(rb.GetLocale());
            iter.SetLocale(uloc, uloc);
            iter.BreakType = kind;

            // filtered break
            if (kind == BreakIterator.KIND_SENTENCE)
            {
                string ssKeyword = locale.GetKeywordValue("ss");
                if (ssKeyword != null && ssKeyword.Equals("standard"))
                {
                    ULocale @base = new ULocale(locale.GetBaseName());
                    return(FilteredBreakIteratorBuilder.GetInstance(@base).WrapIteratorWithFilter(iter));
                }
            }

            return(iter);
        }
예제 #11
0
 public override string LocaleDisplayName(CultureInfo locale)
 {
     return(ULocale.ForLocale(locale).GetName());
 }
예제 #12
0
 /// <summary>
 /// Returns an instance of <see cref="LocaleDisplayNames"/> that returns names formatted for the provided
 /// <see cref="CultureInfo"/>, using the provided <see cref="DisplayContext"/> settings.
 /// </summary>
 /// <param name="locale">The display <see cref="CultureInfo"/>.</param>
 /// <param name="contexts">One or more context settings (e.g. for dialect handling, capitalization, etc.)</param>
 /// <returns>A <see cref="LocaleDisplayNames"/> instance.</returns>
 /// <stable>ICU 54</stable>
 public static LocaleDisplayNames GetInstance(CultureInfo locale, params DisplayContext[] contexts)
 {
     return(GetInstance(ULocale.ForLocale(locale), contexts));
 }
예제 #13
0
 /// <summary>
 /// Convenience overload of <see cref="GetInstance(CultureInfo, DisplayContext[])"/> that specifies
 /// <see cref="DisplayContext.StandardNames"/>.
 /// </summary>
 /// <param name="locale">The display <see cref="CultureInfo"/>.</param>
 /// <returns>A <see cref="LocaleDisplayNames"/> instance.</returns>
 /// <stable>ICU 54</stable>
 public static LocaleDisplayNames GetInstance(CultureInfo locale)
 {
     return(GetInstance(ULocale.ForLocale(locale)));
 }
 public SimpleFilteredSentenceBreakIteratorBuilder(CultureInfo loc)
     : this(ULocale.ForLocale(loc))
 {
 }