private void TranslateProperty <T>(T property, string propertyName, int languageId) where T : BaseEntity { var propertyValue = (typeof(T)).GetProperty(propertyName).GetValue(property, null).ToString(); var lan = GetLocalizedProperty(property.Id, typeof(T).Name, propertyName, propertyValue, languageId); LocalizedEntityService.InsertLocalizedProperty(lan); }
private void TranslateMetaKeywords(NopProduct nopProduct) { foreach (var googleLanguage in GoogleLanguage.Languages) { if (googleLanguage.Id != 1) { string translatedText = null; if (googleLanguage.Id == 2) { translatedText = @"保健品 维生素 抗衰老 医药 在线 护理 健康 美容 产品 减肥 处方药 药物 扑热息痛 皮肤 流感 阿司匹林 奶粉 婴儿食品 母婴用品 儿童 男人 女人 老人 小孩 自然 有机"; } else { var keywords = nopProduct.MetaKeywords.Replace(" ", "/ "); var language = GoogleLanguage.GetLanguageById(googleLanguage.Id); if (language != null && googleLanguage.Id != 1) { translatedText = NopDictionary.GetTranslate(keywords, googleLanguage.Id); if (string.IsNullOrWhiteSpace(translatedText)) { translatedText = Translator.Translate(keywords, "English", GoogleLanguage.GetLanguageById(googleLanguage.Id).Name); translatedText = translatedText.Replace("/", " "); } } } var lan = new LocalizedProperty { EntityId = nopProduct.Id, LanguageId = googleLanguage.Id, LocaleKey = "MetaKeywords", LocaleKeyGroup = "Prodcut", LocaleValue = translatedText }; LocalizedEntityService.InsertLocalizedProperty(lan); } } }