Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Ensures the given localization is at the current version.
        /// </summary>
        /// <param name="locale">The locale representing the required localization.</param>
        /// <param name="caller">The form that is calling this method (used as the owner
        /// of the progress dialog box - can be null if progress dialog is supplied).</param>
        /// <param name="existingProgressDlg">The existing progress dialog box if any.</param>
        /// ------------------------------------------------------------------------------------
        private void EnsureCurrentLocalization(string locale, Form caller, IThreadedProgress existingProgressDlg)
        {
            string localizationFile = FwDirectoryFinder.GetKeyTermsLocFilename(locale);

            if (!FileUtils.FileExists(localizationFile))
            {
                return;                 // There is no localization available for this locale, so we're as current as we're going to get.
            }
            BiblicalTermsLocalization loc;

            try
            {
                loc = DeserializeBiblicalTermsLocFile(localizationFile);
            }
            catch (InstallationException e)
            {
                ErrorReporter.ReportException(e, m_app.SettingsKey, m_app.SupportEmailAddress, caller, false);
                return;
            }

            string resourceName = GetLocalizationResourceName(locale);

            if (IsResourceOutdated(resourceName, loc.Version))
            {
                NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(m_servLoc.GetInstance <IActionHandler>(),
                                                                   () => {
                    existingProgressDlg.RunTask(true, UpdateLocalization, loc, locale);
                    SetNewResourceVersion(resourceName, loc.Version);
                });
            }
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets all the available Key Terms localizations.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual List <BiblicalTermsLocalization> GetLocalizations()
        {
            int defaultUserWs = m_scr.Cache.DefaultUserWs;

            string[] locFiles = FwDirectoryFinder.KeyTermsLocalizationFiles;
            List <BiblicalTermsLocalization> localizations =
                new List <BiblicalTermsLocalization>(locFiles.Length);
            bool fFoundDefaultLoc = false;

            foreach (string localizationFile in locFiles)
            {
                int hvoWs = GetWsFromLocFile(m_wsf, localizationFile);
                if (hvoWs > 0)
                {
                    BiblicalTermsLocalization loc = DeserializeBiblicalTermsLocFile(localizationFile);
                    if (loc != null)
                    {
                        fFoundDefaultLoc    |= (hvoWs == defaultUserWs);
                        loc.WritingSystemHvo = hvoWs;
                        localizations.Add(loc);
                    }
                }
            }
            if (!fFoundDefaultLoc || localizations.Count == 0)
            {
                string icuLocale = m_wsf.GetStrFromWs(defaultUserWs);
                string message   = String.Format("File {0} is missing", FwDirectoryFinder.GetKeyTermsLocFilename(icuLocale));
                Debug.Fail(message);
                Logger.WriteEvent(message);
                if (icuLocale == "en" || localizations.Count == 0)
                {
#if !DEBUG
                    message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
                    throw new InstallationException(message, null);
                }
            }
            return(localizations);
        }