예제 #1
0
        /// <summary>
        /// Gets the CDRID (definition term) for the language toggle using the current defintion term in the URL.
        /// If a friendly name is given, it determines the CDRID from it.
        /// </summary>
        private string GetCDRIDForLanguageToggle(string translationLang)
        {
            string cdridForLangToggle = CdrID;

            if (!string.IsNullOrEmpty(this.GetDefinitionParam()))
            {
                // Get friendly name to CDRID mappings
                string dictionaryMappingFilepath = null;

                dictionaryMappingFilepath = this.DictionaryConfiguration.Files.Single(a => a.Locale == translationLang).Filepath;

                if (!string.IsNullOrEmpty(dictionaryMappingFilepath))
                {
                    TerminologyMapping map = TerminologyMapping.GetMappingForFile(dictionaryMappingFilepath);

                    // If pretty name is in label mappings, set CDRID
                    if (map.MappingContainsCDRID(cdridForLangToggle))
                    {
                        cdridForLangToggle = map.GetFriendlyNameFromCDRID(cdridForLangToggle);
                    }
                }
            }

            return(cdridForLangToggle);
        }
        /// <summary>
        /// Gets the friendly name of the given CDRID, if it exists.
        /// Otherwise, returns the CDRID.
        /// </summary>
        public string GetFriendlyName(DictionaryInfo info, string cdrId)
        {
            // Get CDRID to friendly name mappings
            string dictionaryMappingFilepath = null;

            dictionaryMappingFilepath = info.FriendlyNameMapping;

            if (!string.IsNullOrEmpty(dictionaryMappingFilepath))
            {
                TerminologyMapping map = TerminologyMapping.GetMappingForFile(dictionaryMappingFilepath);

                // If pretty name is in label mappings, set CDRID
                if (map.MappingContainsCDRID(cdrId))
                {
                    return(map.GetFriendlyNameFromCDRID(cdrId));
                }
            }

            return(cdrId);
        }
예제 #3
0
        /// <summary>
        /// Gets the friendly name of the given CDRID param, if it exists.
        /// Otherwise, returns the CDRID param.
        /// </summary>
        public string GetFriendlyName(string cdrId)
        {
            // Get CDRID to friendly name mappings
            string dictionaryMappingFilepath = null;

            dictionaryMappingFilepath = this.DictionaryConfiguration.Files.Single(a => a.Locale == CultureInfo.CurrentUICulture.TwoLetterISOLanguageName).Filepath;

            if (!string.IsNullOrEmpty(dictionaryMappingFilepath))
            {
                TerminologyMapping map = TerminologyMapping.GetMappingForFile(dictionaryMappingFilepath);

                // If pretty name is in label mappings, set CDRID
                if (map.MappingContainsCDRID(cdrId))
                {
                    return(map.GetFriendlyNameFromCDRID(cdrId));
                }
            }

            return(cdrId);
        }