示例#1
0
        public void AddNewTranslationToManager(string key, string defaultString)
        {
            TranslationWrapper translation = new TranslationWrapper(TUA.instance.CreateTranslation(key)); TUA.instance.CreateTranslation(key);

            translation.SetDefault(defaultString);
            manager.Add(key, translation);
        }
示例#2
0
        public static void SetMessageTranslation(TranslationWrapper translation)
        {
            DefineLanguage(translation.NewLang);
            MessageTranslation trl = new MessageTranslation();

            trl.Message      = translation.Component;
            trl.MessageGroup = translation.Form;
            trl.Language     = translation.NewLang;
            trl.Translation  = translation.Translation;
            trl.Translated   = true;
            Crud.Put(trl);
        }
示例#3
0
        public static void SetFormTranslation(TranslationWrapper translation)
        {
            DefineLanguage(translation.NewLang);
            FormTranslation trl = new FormTranslation();

            trl.Component   = translation.Component;
            trl.Form        = translation.Form;
            trl.Language    = translation.NewLang;
            trl.Translation = translation.Translation;
            trl.Translated  = true;
            Crud.Put(trl);
        }
示例#4
0
        public static IList <TranslationWrapper> GetMessageTranslationsByForm(string messageGroup, string language, bool onlyNotTranslated)
        {
            IList <TranslationWrapper> resultList = new List <TranslationWrapper>();

            using (var session = DataConnector.NHibernateConnector.OpenSession())
            {
                IList <MessageTranslation> fte = session.CreateCriteria(typeof(MessageTranslation))
                                                 .Add(Expression.Eq("Language", "en"))
                                                 .Add(Expression.InsensitiveLike("MessageGroup", "%" + messageGroup + "%"))
                                                 .List <MessageTranslation>();

                foreach (MessageTranslation tr in fte)
                {
                    MessageTranslation ftt = session.CreateCriteria(typeof(MessageTranslation))
                                             .Add(Expression.Eq("Language", language))
                                             .Add(Expression.Eq("MessageGroup", tr.MessageGroup))
                                             .Add(Expression.Eq("Message", tr.Message))
                                             .UniqueResult <MessageTranslation>();
                    if ((onlyNotTranslated && string.IsNullOrEmpty(ftt?.Translation)) || !onlyNotTranslated)
                    {
                        TranslationWrapper tw = new TranslationWrapper();
                        tw.Form        = tr.MessageGroup;
                        tw.Component   = tr.Message;
                        tw.English     = tr.Translation;
                        tw.NewLang     = language;
                        tw.Translation = "";
                        if (!(string.IsNullOrEmpty(ftt?.Translation)))
                        {
                            tw.Translation = ftt.Translation;
                        }
                        resultList.Add(tw);
                    }
                }
            }
            return(resultList);
        }