public override void UpdateSource(IEnumerable <LocalizedContent> localizedContent)
 {
     foreach (LocalizedContent lk in localizedContent)
     {
         TranslationKey      key           = lk.LocalizationKey as TranslationKey;
         TranslationGroupKey groupKey      = TranslationGroupKey.CreateManager(2).Load(key.Translation, lk.Group, lk.Key);
         TranslationValue    existingValue = TranslationValue.CreateManager().Load(lk.LocalizationKey as TranslationKey, groupKey);
         if (existingValue != null)
         {
             if (lk.Value == null)
             {
                 existingValue.Delete();
             }
             else if (!existingValue.Value.Equals(lk.Value))
             {
                 existingValue.Value = lk.Value;
                 existingValue.Update();
             }
         }
         else if (lk.Value != null)
         {
             TranslationValue newValue = new TranslationValue(-1, key, groupKey, lk.Value, DateTime.Now, DateTime.Now);
             newValue.Insert();
         }
     }
 }
예제 #2
0
        public ActionResult ApiUpdateTranslationValue(string translationValueKeyID, string translationKeyID, string translationGroupKeyID, string groupName, string groupKey, string value)
        {
            int tvalueID, tKeyID, tGroupKeyID;

            if (!Int32.TryParse(translationValueKeyID, out tvalueID))
            {
                return(this.Json(new { status = false, message = "Argument error 'translationValueKeyID" }));
            }
            if (!Int32.TryParse(translationKeyID, out tKeyID))
            {
                return(this.Json(new { status = false, message = "Argument error 'translationKeyID" }));
            }
            if (!Int32.TryParse(translationGroupKeyID, out tGroupKeyID))
            {
                return(this.Json(new { status = false, message = "Argument error 'translationGroupKeyID" }));
            }

            string message = "";

            value = HttpUtility.UrlDecode(value);

            TranslationValue translationValue;

            if (tvalueID == -1)
            {
                translationValue = new TranslationValue(-1,
                                                        TranslationKey.CreateManager().Load(tKeyID),
                                                        TranslationGroupKey.CreateManager().Load(tGroupKeyID),
                                                        value,
                                                        DateTime.Now, DateTime.Now);
                translationValue.Insert();
                message = "Translation has been added";
            }
            else
            {
                translationValue = TranslationValue.CreateManager().Load(tvalueID);
                if (translationValue == null)
                {
                    return(this.Json(new { status = false, message = "Translation value does not exists!" }));
                }

                translationValue.Value = value;
                translationValue.Update();
                message = "Translation has been updated";
            }

            Translations.Web.GetGroup(groupName).AssignValue(groupKey, value);
            //MobiContext.Current.UpdateTranslationsWildcars();

            return(this.Json(new { status = true, message = message, id = translationValue.ID, Updated = translationValue.Updated.ToString() }));
        }
예제 #3
0
        public TranslationTemplateModel(MobiContext context, Translation translation, bool extendedAccess, string groupName)
            : base(context, extendedAccess)
        {
            this._translationKey = TranslationKey.CreateManager().Load(context.Service.ServiceData);
            if (this._translationKey == null)
            {
                this._hasTranslation = false;
                return;
            }

            this.Name              = groupName;
            this._fallbackKey      = this._translationKey.FallbackTranslationKey;
            this._translationGroup = TranslationGroup.CreateManager().Load(translation, groupName);

            this._values = new List <TranslationValueTemplate>();
            List <TranslationGroupKey> groupKeys = TranslationGroupKey.CreateManager().Load(this._translationGroup);

            foreach (TranslationGroupKey groupKey in groupKeys)
            {
                this._values.Add(new TranslationValueTemplate(this._translationKey, this._fallbackKey, groupKey));
            }
        }
 protected override IEnumerable <LocalizationGroupKey> LoadLocalizationGroupKeys()
 {
     return(from TranslationGroupKey t in (TranslationGroupKey.CreateManager(3).Load(this.Translation))
            select new LocalizationGroupKey(t.TranslationGroup.Translation.Name,
                                            t.TranslationGroup.Name, t.Name, t.Comment));
 }