FormatResourceString() public static method

Return a string from a resource ID, with formatting placeholders replaced by the supplied parameters.
public static FormatResourceString ( string stid ) : string
stid string String resource id
return string
Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Update the existing categories and terms with new localized strings.
        /// </summary>
        /// <param name="dlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: 1) the BiblicalTermsLocalization object
        /// representing the contents of the XML file with the localized strings; 2) The ICU
        /// locale (string).</param>
        /// <returns>always null</returns>
        /// ------------------------------------------------------------------------------------
        protected object UpdateLocalization(IThreadedProgress dlg, params object[] parameters)
        {
            BiblicalTermsLocalization loc = (BiblicalTermsLocalization)parameters[0];
            string locale = (string)parameters[1];

            const int kcStepsToBuildLookupTable = 4;

            dlg.Position = 0;
            dlg.Minimum  = 0;
            dlg.Maximum  = loc.Categories.Count + loc.Terms.Count + kcStepsToBuildLookupTable;
            dlg.Title    = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBCaption");
            dlg.Message  = TeResourceHelper.FormatResourceString("kstidLoadKeyTermsLocalizations",
                                                                 m_wsf.get_Engine(locale).LanguageName);

            m_wsDefault = m_servLoc.WritingSystemManager.GetWsFromStr("en");

            int hvoLocWs = loc.WritingSystemHvo = m_wsf.GetWsFromStr(locale);

            IEnumerable <ICmPossibility> categories = ((ILangProject)m_scr.Owner).KeyTermsList.PossibilitiesOS;

            foreach (CategoryLocalization localizedCategory in loc.Categories)
            {
                ICmPossibility category = categories.FirstOrDefault(
                    p => p.Abbreviation.get_String(m_wsDefault).Text == localizedCategory.Id);
                if (category != null)
                {
                    category.Name.set_String(hvoLocWs, localizedCategory.Gloss);
                }
                dlg.Step(1);
            }

            Dictionary <int, IChkTerm> termLookupTable =
                m_servLoc.GetInstance <IChkTermRepository>().AllInstances().ToDictionary(t => t.TermId);

            dlg.Step(kcStepsToBuildLookupTable);

            IChkTerm term;
            string   message = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBStatus");

            foreach (TermLocalization localizedTerm in loc.Terms)
            {
                dlg.Message = string.Format(message, localizedTerm.Gloss);

                if (termLookupTable.TryGetValue(localizedTerm.Id, out term))
                {
                    SetLocalizedGlossAndDescription(term, localizedTerm, loc.WritingSystemHvo);
                }
                dlg.Step(1);
            }
            return(null);
        }