Esempio n. 1
0
        /**
         * Registers standard variants with the system.  Called by
         * Transliterator during initialization.
         */
        internal static void Register()
        {
            // false means that it is invisible
            Transliterator trans = new BreakTransliterator("Any-BreakInternal", null);

            Transliterator.RegisterInstance(trans, false);

            /*
             * Transliterator.registerFactory("Any-Break", new Transliterator.Factory() {
             *  public Transliterator getInstance(String ID) {
             *      return new BreakTransliterator("Any-Break", null);
             *  }
             * });
             */
        }
Esempio n. 2
0
        /// <summary>
        /// Registers standard transliterators with the system.  Called by
        /// <see cref="Transliterator"/> during initialization.  Scan all current targets
        /// and register those that are scripts T as Any-T/V.
        /// </summary>
        internal static void Register()
        {
            IDictionary <string, ISet <string> > seen = new Dictionary <string, ISet <string> >(); // old code used set, but was dependent on order

            foreach (string source in Transliterator.GetAvailableSources())
            {
                // Ignore the "Any" source
                if (source.Equals(ANY, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                foreach (string target in Transliterator.GetAvailableTargets(source))
                {
                    // Get the script code for the target.  If not a script, ignore.
                    int targetScript = ScriptNameToCode(target);
                    if (targetScript == UScript.InvalidCode)
                    {
                        continue;
                    }

                    ISet <string> seenVariants = seen.Get(target);
                    if (seenVariants == null)
                    {
                        seen[target] = seenVariants = new HashSet <string>();
                    }

                    foreach (string variant in Transliterator.GetAvailableVariants(source, target))
                    {
                        // Only process each target/variant pair once
                        if (seenVariants.Contains(variant))
                        {
                            continue;
                        }
                        seenVariants.Add(variant);

                        string id;
                        id = TransliteratorIDParser.STVtoID(ANY, target, variant);
                        AnyTransliterator trans = new AnyTransliterator(id, target, variant,
                                                                        targetScript);
                        Transliterator.RegisterInstance(trans);
                        Transliterator.RegisterSpecialInverse(target, NULL_ID, false);
                    }
                }
            }
        }