コード例 #1
0
        /// <summary>
        /// If there are no pronunciation writing systems selected, make a default set, with IPA variants
        /// coming before EMC variants (if either of those exist).  If neither exists, the primary
        /// vernacular writing system is selected.
        /// </summary>
        private void InitializePronunciationWritingSystems()
        {
            if (m_currentPronunciationWritingSystems.Count > 0)
            {
                return;
            }

            NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(Cache.ActionHandlerAccessor,
                                                               () =>
            {
                var writingSystems = m_vernacularWritingSystems;
                var wsVern         = DefaultVernacularWritingSystem;
                var sVern          = wsVern.IcuLocale.ToLower();
                var idx            = sVern.IndexOf("_");
                sVern = idx > 0 ? sVern.Substring(0, idx + 1) : sVern + '_';
                // Add any relevant IPA writing systems: those that match the default vernacular at the start and end with _ipa
                foreach (var nws in writingSystems)
                {
                    var icuLocale = nws.IcuLocale.ToLower();
                    if (icuLocale.IndexOf(sVern) != 0)
                    {
                        continue;
                    }

                    idx = icuLocale.LastIndexOf("_ipa");
                    if (idx >= sVern.Length && idx == icuLocale.Length - 4)
                    {
                        m_currentPronunciationWritingSystems.Add(nws);
                    }
                }
                // Add any relevant EMC writing systems: match default vern at start and end with _emc.
                foreach (var nws in writingSystems)
                {
                    var icuLocale = nws.IcuLocale.ToLower();
                    if (icuLocale.IndexOf(sVern) != 0)
                    {
                        continue;
                    }

                    idx = icuLocale.LastIndexOf("_emc");
                    if (idx < sVern.Length || idx != icuLocale.Length - 4)
                    {
                        continue;
                    }

                    m_currentPronunciationWritingSystems.Add(nws);
                }
                // Add the primary vernacular writing system if nothing else fits.
                if (m_currentPronunciationWritingSystems.Count == 0)
                {
                    m_currentPronunciationWritingSystems.Add(wsVern);
                }
            });
        }
コード例 #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the given writing system to the current vernacular writing systems
 /// and also to the collection of all vernacular writing systems if necessary.
 /// </summary>
 /// <param name="ws">The writing system to add.</param>
 /// ------------------------------------------------------------------------------------
 public void AddToCurrentVernacularWritingSystems(IWritingSystem ws)
 {
     m_vernacularWritingSystems.Add(ws);
     m_currentVernacularWritingSystems.Add(ws);
 }
コード例 #3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the given writing system to the current vernacular writing systems
 /// and also to the collection of all vernacular writing systems if necessary.
 /// </summary>
 /// <param name="ws">The writing system to add.</param>
 /// ------------------------------------------------------------------------------------
 public void AddToCurrentVernacularWritingSystems(CoreWritingSystemDefinition ws)
 {
     m_vernacularWritingSystems.Add(ws);
     m_currentVernacularWritingSystems.Add(ws);
 }
コード例 #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the given writing system to the current analysis writing systems
 /// and also to the collection of all analysis writing systems if necessary.
 /// </summary>
 /// <param name="ws">The writing system to add.</param>
 /// ------------------------------------------------------------------------------------
 public void AddToCurrentAnalysisWritingSystems(IWritingSystem ws)
 {
     m_analysisWritingSystems.Add(ws);
     m_currentAnalysisWritingSystems.Add(ws);
 }
コード例 #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the given writing system to the current analysis writing systems
 /// and also to the collection of all analysis writing systems if necessary.
 /// </summary>
 /// <param name="ws">The writing system to add.</param>
 /// ------------------------------------------------------------------------------------
 public void AddToCurrentAnalysisWritingSystems(CoreWritingSystemDefinition ws)
 {
     m_analysisWritingSystems.Add(ws);
     m_currentAnalysisWritingSystems.Add(ws);
 }