예제 #1
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() }));
        }
예제 #2
0
        public override ILocalizationKey GetKey(string[] values)
        {
            if (values.Length < 3)
            {
                return(null);
            }
            //string productName = values[0];
            //if (string.IsNullOrEmpty(productName))
            //	return null;
            //
            //string localizationId = values[0];
            //if (string.IsNullOrEmpty(localizationId))
            //	return null;
            //Data.Localization localization = Data.Localization.CreateManager().Load(Int32.Parse(localizationId));
            //
            //Product product = Product.CreateManager().Load(productName);
            //if (product == null)
            //	return null;
            //Translation translation = Translation.CreateManager().Load<Translation>(product);

            string translationKeyId = values[0];

            if (string.IsNullOrEmpty(translationKeyId))
            {
                return(null);
            }
            TranslationKey tk = TranslationKey.CreateManager().Load(Int32.Parse(translationKeyId));

            Translation translation = tk.Translation;

            if (translation == null)
            {
                return(null);
            }
            string   languageCode = values[1];
            Language language     = null;

            if (!string.IsNullOrEmpty(languageCode))
            {
                language = Language.CreateManager().Load(languageCode, LanguageIdentifier.TwoLetterIsoCode);
            }
            string  serviceName = values[2];
            Service service     = null;

            if (!string.IsNullOrEmpty(serviceName))
            {
                service = Service.CreateManager().Load(serviceName);
            }

            return(new TranslationKey(translation, language, service));
        }
예제 #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 <ILocalizationKey> LoadLocalizationKeys()
 {
     return(from TranslationKey key in (TranslationKey.CreateManager(3).Load(this.Translation))
            select key);
 }