示例#1
0
        /// <summary>
        /// Fill untranslated resource.
        /// </summary>
        /// <param name="defaultResource"></param>
        /// <param name="localeResources"></param>
        /// <param name="locale"></param>
        protected static void FillResource(Canon.Data.Localization defaultResource, List <Canon.Data.Localization> localeResources, string locale)
        {
            var localeResource = from lr in localeResources
                                 where lr.ResourceSet == defaultResource.ResourceSet &&
                                 lr.ResourceId == defaultResource.ResourceId
                                 select lr;

            if (localeResource.Count() == 0)
            {
                Canon.Data.Localization localization = new Canon.Data.Localization();
                localization.ResourceId  = defaultResource.ResourceId;
                localization.Value       = defaultResource.Value;
                localization.LocaleId    = locale;
                localization.ResourceSet = defaultResource.ResourceSet;
                localization.Type        = defaultResource.Type;
                localization.BinFile     = defaultResource.BinFile;
                localization.TextFile    = defaultResource.TextFile;
                localization.Filename    = defaultResource.Filename;

                InsertLocalization(localization);
            }
            else
            {
                Canon.Data.Localization localization = localeResource.First();

                if (localization.Value != String.Empty)
                {
                    return;
                }

                localization.Value = defaultResource.Value;

                UpdateLocalization(localization);
            }
        }
示例#2
0
        /// <summary>
        /// Insert new localization.
        /// </summary>
        /// <param name="localization"></param>
        protected static void InsertLocalization(Canon.Data.Localization localization)
        {
            CanonDataContext db = Cdb.Instance;

            db.Localizations.InsertOnSubmit(localization);
            db.SubmitChanges();
        }
示例#3
0
        /// <summary>
        /// Update localization.
        /// </summary>
        /// <param name="localization"></param>
        protected static void UpdateLocalization(Canon.Data.Localization localization)
        {
            CanonDataContext db = Cdb.Instance;

            if (db.Localizations.GetOriginalEntityState(localization) == null)
            {
                db.Localizations.Attach(localization, false);
                db.Refresh(RefreshMode.KeepCurrentValues, localization);
            }

            db.SubmitChanges();
        }
示例#4
0
        /// <summary>
        /// Fill untranslated resource.
        /// </summary>
        /// <param name="defaultResource"></param>
        /// <param name="localeResources"></param>
        /// <param name="locale"></param>
        protected static void FillResource(Canon.Data.Localization defaultResource, List<Canon.Data.Localization> localeResources, string locale)
        {
            var localeResource = from lr in localeResources
                                 where lr.ResourceSet == defaultResource.ResourceSet &&
                                 lr.ResourceId == defaultResource.ResourceId
                                 select lr;

            if (localeResource.Count() == 0)
            {
                Canon.Data.Localization localization = new Canon.Data.Localization();
                localization.ResourceId = defaultResource.ResourceId;
                localization.Value = defaultResource.Value;
                localization.LocaleId = locale;
                localization.ResourceSet = defaultResource.ResourceSet;
                localization.Type = defaultResource.Type;
                localization.BinFile = defaultResource.BinFile;
                localization.TextFile = defaultResource.TextFile;
                localization.Filename = defaultResource.Filename;

                InsertLocalization(localization);
            }
            else
            {
                Canon.Data.Localization localization = localeResource.First();

                if (localization.Value != String.Empty)
                {
                    return;
                }

                localization.Value = defaultResource.Value;

                UpdateLocalization(localization);
            }
        }