예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Finds or creates the writing system.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="icuLocale">The icu locale.</param>
        /// <returns>The writing system</returns>
        /// ------------------------------------------------------------------------------------
        private LgWritingSystem FindOrCreateWs(FdoCache cache, string icuLocale)
        {
            // Look to see if the writing system already exists in the database
            foreach (LgWritingSystem ws in cache.LanguageEncodings)
            {
                if (LanguageDefinition.SameLocale(ws.ICULocale, icuLocale))
                {
                    return(ws);
                }
            }

            // Create a new writing system based on the one noted in the XML file.
            // Load it in from the XML and save into the database.
            LanguageDefinitionFactory ldf =
                new LanguageDefinitionFactory(cache.LanguageWritingSystemFactoryAccessor, icuLocale);

            ldf.LanguageDefinition.SaveWritingSystem(icuLocale);
            cache.ResetLanguageEncodings();
            // search again. It better be there now!
            foreach (LgWritingSystem ws in cache.LanguageEncodings)
            {
                if (LanguageDefinition.SameLocale(ws.ICULocale, icuLocale))
                {
                    return(ws);
                }
            }
            Debug.Assert(false);
            return(null);
        }
예제 #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Looks up the ICU locale and returns the corresponding writing system code
 /// </summary>
 /// <param name="sICULocale">The ICU locale name</param>
 /// <returns>The Writing System code</returns>
 /// ------------------------------------------------------------------------------------
 public int GetWsFromIcuLocale(string sICULocale)
 {
     foreach (ILgWritingSystem lgws in this)
     {
         if (LanguageDefinition.SameLocale(lgws.ICULocale, sICULocale))
         {
             return(lgws.Hvo);
         }
     }
     return(0);            // Couldn't find it.
 }