/// <summary> /// Add the specified writing system to your pronunciations, if it starts with the right prefix /// and ends with the right suffix. /// </summary> private void AddWsToPronunciations(NamedWritingSystem nws, string sPrefix, string sSuffix) { int idx; string icuLocale = nws.IcuLocale.ToLowerInvariant(); if (icuLocale.IndexOf(sPrefix) == 0) { idx = icuLocale.LastIndexOf(sSuffix); if (idx >= sPrefix.Length && idx == icuLocale.Length - sSuffix.Length) CurPronunWssRS.Append(nws.Hvo); } }
/// -------------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="ws"></param> /// <param name="list"></param> /// <param name="handler">OnClick event handler</param> /// -------------------------------------------------------------------------------- public WsMenuItem(NamedWritingSystem ws, ListBox list, EventHandler handler) : base(ws.ToString(), null, handler) { m_ws = ws; m_list = list; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds all of the LgWritingSystems in source to the namedWritingSystems set. /// </summary> /// <param name="namedWritingSystems"></param> /// <param name="source"></param> /// <param name="displayLocale">REVIEW (TimS): Looks like this param is not used (maybe /// used to be used). Is there a plan to use it or can it be removed?</param> /// ------------------------------------------------------------------------------------ private static void AddWsNamedObjsToSet(Set<NamedWritingSystem> namedWritingSystems, IEnumerable source, string displayLocale) { foreach (LgWritingSystem ws in source) { NamedWritingSystem nws = new NamedWritingSystem(ws.ShortName, ws.ICULocale, ws.Hvo); // TE-6958 kept crashing when we tried to get a hashcode for a malformed ws. Instead // of crashing, let's just skip the bum ws. It's still a mystery how we apparently get // a ws without a name since the name will default to the IcuLocale if it is missing. if (nws.Name != null && nws.IcuLocale != null) namedWritingSystems.Add(nws); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new language project for the new language name /// </summary> /// <param name="progressDlg">The progress dialog.</param> /// <param name="parameters">The parameters: first parameter is resources, second is /// name of the project (string), analysis and vernacular writing system /// (NamedWritingSystem).</param> /// <returns>Always null.</returns> /// <remarks>Override DisplayUi to prevent progress dialog from showing.</remarks> /// ------------------------------------------------------------------------------------ protected internal object CreateNewLangProj(IAdvInd4 progressDlg, params object[] parameters) { Debug.Assert(parameters.Length == 4); ResourceManager resources = (ResourceManager)parameters[0]; string projectName = (string)parameters[1]; m_analWrtSys = (NamedWritingSystem)parameters[2]; m_vernWrtSys = (NamedWritingSystem)parameters[3]; string dbFileName; string logFileName; // Loading the new language project (LoadNewLangProj) took 120 steps. To be safe // we calculate with 140. Loading newlangproj took 94% of the time, so the total is // 150. int nMax = 150; progressDlg.SetRange(0, nMax); if (resources != null) progressDlg.Message = resources.GetString("kstidCreatingDB"); CreateNewDbFiles(projectName, out dbFileName, out logFileName); progressDlg.Step(0); m_dbName = AttachDatabase(dbFileName, logFileName); progressDlg.Step(0); if (resources != null) progressDlg.Message = resources.GetString("kstidInitializingDB"); LoadNewLangProj(progressDlg); // Create the FDO cache and writing systems. progressDlg.Position = (int)(nMax * 0.95); if (resources != null) progressDlg.Message = resources.GetString("kstidCreatingWS"); int hvoLp = 0; using (FdoCache cache = FdoCache.Create(m_dbName)) { progressDlg.Step(0); CreateAnalysisWritingSystem(cache); progressDlg.Step(0); CreateVernacularWritingSystem(cache); // Fix sort methods that should use the vernacular writing system. progressDlg.Step(0); progressDlg.Step(0); FixVernacularWritingSystemReferences(cache); progressDlg.Step(0); // set defaults so can access them now cache.LangProject.CacheDefaultWritingSystems(); progressDlg.Step(0); AssignVernacularWritingSystemToDefaultPhPhonemes(cache); progressDlg.Step(0); // Create a reversal index for the original default analysis writing system. (LT-4480) IReversalIndex newIdx = cache.LangProject.LexDbOA.ReversalIndexesOC.Add( new ReversalIndex()); ILgWritingSystem wsAnalysis = cache.LangProject.CurAnalysisWssRS[0]; newIdx.WritingSystemRA = wsAnalysis; newIdx.Name.AnalysisDefaultWritingSystem = wsAnalysis.Name.AnalysisDefaultWritingSystem; progressDlg.Step(0); // Give the language project a default name. Later this can be modified by the // user by changing it on the project properties dialog. cache.LangProject.Name.UserDefaultWritingSystem = projectName; hvoLp = cache.LangProject.Hvo; cache.Save(); progressDlg.Position = nMax; } return new NewLangProjReturnData(hvoLp, m_serverName, m_dbName); }