Пример #1
0
        public virtual TitleDescriptionObjectTranslation GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage, Boolean firstIsMulti, Boolean useFirstOccurence)
        {
            TitleDescriptionObjectTranslation translation = null;

            if (Translations == null || Translations.Any())
            {
                translation = Translations.Where(t => t.IdLanguage == idUserLanguage).FirstOrDefault().Translation;
            }
            if (translation == null && DefaultTranslation.IsValid() && firstIsMulti)
            {
                translation = DefaultTranslation;
            }
            if (translation == null && Translations.Any())
            {
                translation = Translations.Where(t => t.IdLanguage == idDefaultLanguage).FirstOrDefault().Translation;
            }
            if (translation == null && Translations.Any() && useFirstOccurence)
            {
                translation = Translations.FirstOrDefault().Translation;
            }
            return((translation == null) ? new TitleDescriptionObjectTranslation()
            {
                Title = Id.ToString()
            } : translation);
        }
Пример #2
0
        internal bool TypeIsWrapped(Type type)
        {
            if (type == typeof(NodeList))
            {
                Console.WriteLine("BREAK!!");
            }

            if (type == typeof(Map))
            {
                Console.WriteLine("BREAK!!");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (type.FullName == null)
            {
                throw new ArgumentException("type");
            }

            bool translationOk = Translations.Any(trans => type.FullName.StartsWith(trans.Key));

            return /* type.Assembly == TargetAssembly && */ (translationOk &&
                                                             !type.IsNested /* && !type.IsInterface */ && !type.IsArray);
        }
Пример #3
0
        private bool HasTranslation()
        {
            if (Translations == null || Translations.Count < 1)
            {
                return(false);
            }

            return(!Translations.Any(x => string.IsNullOrWhiteSpace(x.Translation)));
        }
Пример #4
0
        public virtual String GetTranslation(String userLanguageCode, Int32 idDefaultLanguage)
        {
            String translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? ToolTip : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Select(t => t.ToolTip).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.ToolTip).FirstOrDefault();

            if (String.IsNullOrEmpty(translation))
            {
                translation = ToolTip;
            }
            return(translation);
        }
Пример #5
0
        public ItemObjectTranslation GetTranslation(String userLanguageCode, Int32 idDefaultLanguage)
        {
            ItemObjectTranslation translation = (Translations == null || !Translations.Any()) ? DefaultTranslation : (Translations.Where(t => t.LanguageCode == userLanguageCode).Any()) ? Translations.Where(t => t.LanguageCode == userLanguageCode).Select(t => t.Translation).FirstOrDefault() : Translations.Where(t => t.IdLanguage == idDefaultLanguage).Select(t => t.Translation).FirstOrDefault();

            if (translation == null)
            {
                translation = DefaultTranslation;
            }
            return(translation);
        }
Пример #6
0
        public String GetName(Int32 idUserLanguage, Int32 idDefaultLanguage)
        {
            String name = (Translations == null || !Translations.Any()) ? DefaultTranslation.Name : (Translations.Where(t => t.IdLanguage == idUserLanguage).Any()) ? Translations.Where(t => t.IdLanguage == idUserLanguage).Select(t => t.Translation.Name).FirstOrDefault() : Translations.Where(t => t.IdLanguage == idDefaultLanguage).Select(t => t.Translation.Name).FirstOrDefault();

            if (String.IsNullOrEmpty(name))
            {
                name = DefaultTranslation.Name;
            }
            return(name);
        }
Пример #7
0
        public virtual String GetLowerTitle(Int32 idUserLanguage, Int32 idDefaultLanguage)
        {
            String name = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? DefaultTranslation.Title : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Select(t => t.Translation.Title).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.Translation.Title).FirstOrDefault();

            if (String.IsNullOrEmpty(name))
            {
                name = DefaultTranslation.Title;
            }
            return(String.IsNullOrEmpty(name) ? "" : name.ToLower());
        }
Пример #8
0
        public ItemObjectTranslation GetTranslation(String userLanguageCode, Int32 idDefaultLanguage)
        {
            ItemObjectTranslation translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? DefaultTranslation : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Select(t => t.Translation).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.Translation).FirstOrDefault();

            if (translation == null || !translation.IsValid())
            {
                translation = DefaultTranslation;
            }
            return(translation);
        }
 private string GetMessageTranslation(Problem problem, string Language)
 {
     if (Translations.Any(x => x.Code == problem.ErrorCode.Value))
     {
         return(Translations.FirstOrDefault(x => x.Code == problem.ErrorCode.Value && x.Language == Language).Text);
     }
     else
     {
         return(problem.ErrorCode.Value);
     }
 }
        private bool IsCultureNameMatched()
        {
            if (!_configuration.ConstrainTranslatedRoutesByCurrentUICulture)
            {
                return(true);
            }

            // If no translations are available, then obviously the answer is yes.
            if (!_configuration.TranslationProviders.Any())
            {
                return(true);
            }

            var currentUICultureName        = Thread.CurrentThread.CurrentUICulture.Name;
            var currentUINeutralCultureName = currentUICultureName.Split('-').First();

            // If this is a translated route:
            if (DefaultRoute != null)
            {
                // Match if the current UI culture matches the culture name of this route.
                if (currentUICultureName.ValueEquals(CultureName))
                {
                    return(true);
                }

                // Match if the culture name is neutral and no translation exists for the specific culture.
                if (CultureName.Split('-').Length == 1 &&
                    currentUINeutralCultureName == CultureName &&
                    !DefaultRoute.Translations.Any(t => t.CultureName.ValueEquals(currentUICultureName)))
                {
                    return(true);
                }
            }
            else
            {
                // If this is a default route:

                // Match if this route has no translations.
                if (!Translations.Any())
                {
                    return(true);
                }

                // Match if this route has no translations for the neutral current UI culture.
                if (!Translations.Any(t => t.CultureName == currentUINeutralCultureName))
                {
                    return(true);
                }
            }

            // Otherwise, don't match.
            return(false);
        }
Пример #11
0
 public virtual Boolean IsEmptyForLanguage(Int32 idLanguage)
 {
     if (idLanguage <= 0)
     {
         return(String.IsNullOrEmpty(DefaultTranslation.Title));
     }
     else
     {
         return(Translations == null || !Translations.Any()
                ||
                (!Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idLanguage && !String.IsNullOrEmpty(t.Translation.Title)).Any()));
     }
 }
Пример #12
0
        public virtual liteTagTranslation GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage, String dLanguageName, String dLanguageCode)
        {
            liteTagTranslation translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? null : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).FirstOrDefault();

            if (translation == null)
            {
                translation = new liteTagTranslation()
                {
                    IdLanguage = 0, LanguageCode = dLanguageCode, LanguageName = dLanguageName, Translation = DefaultTranslation
                }
            }
            ;
            return(translation);
        }
Пример #13
0
        private ItemTranslation GetTranslation(Int32 idLanguage, Int32 idDefault)
        {
            ItemTranslation translation = GetTranslation(idLanguage);

            if (translation == null)
            {
                translation = GetTranslation(idDefault);
                if (translation == null && Translations.Any())
                {
                    translation = Translations.FirstOrDefault();
                }
            }
            return(translation);
        }
Пример #14
0
        public virtual object Clone()
        {
            liteTileItem clone = new liteTileItem();

            clone.Type        = Type;
            clone.CssClass    = CssClass;
            clone.ToolTip     = ToolTip;
            clone.NavigateUrl = NavigateUrl;
            if (Translations.Any())
            {
                clone.Translations = Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Select(t => (liteTileItemTranslation)t.Clone()).ToList();
            }
            clone.Deleted = Deleted;
            clone.Id      = Id;
            return(clone);
        }
        private VirtualPathData GetTranslatedVirtualPath(VirtualPathData virtualPathData, RequestContext requestContext, RouteValueDictionary values)
        {
            if (Translations == null || !Translations.Any())
            {
                return(virtualPathData);
            }

            var currentCultureName = Thread.CurrentThread.CurrentUICulture.Name;

            // Try and get the language-culture translation, then fall back to language translation
            var translation = Translations.FirstOrDefault(t => t.CultureName == currentCultureName)
                              ?? Translations.FirstOrDefault(t => currentCultureName.StartsWith(t.CultureName));

            if (translation == null)
            {
                return(virtualPathData);
            }

            return(translation.GetVirtualPath(requestContext, values));
        }
Пример #16
0
        public virtual String GetFirstLetter(Int32 idLanguage)
        {
            String title = "";

            if (idLanguage <= 0)
            {
                title = DefaultTranslation.Title;
            }
            else
            {
                title = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? "" : Translations.Where(t => t.IdLanguage == idLanguage).Select(t => t.Translation.Title).FirstOrDefault();
            }

            if (String.IsNullOrEmpty(title))
            {
                return("");
            }
            else
            {
                return(title[0].ToString().ToLower());
            }
        }
Пример #17
0
        public virtual String GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage, Boolean firstIsMulti, Boolean useFirstOccurence)
        {
            String translation = "";

            if (Translations == null || Translations.Any())
            {
                translation = Translations.Where(t => t.IdLanguage == idUserLanguage).FirstOrDefault().ToolTip;
            }
            if (String.IsNullOrEmpty(translation) && !String.IsNullOrEmpty(ToolTip) && firstIsMulti)
            {
                translation = ToolTip;
            }
            if (String.IsNullOrEmpty(translation) && Translations.Any())
            {
                translation = Translations.Where(t => t.IdLanguage == idDefaultLanguage).FirstOrDefault().ToolTip;
            }
            if (String.IsNullOrEmpty(translation) && Translations.Any() && useFirstOccurence)
            {
                translation = Translations.FirstOrDefault().ToolTip;
            }
            return((String.IsNullOrEmpty(translation)) ? Id.ToString() : translation);
        }
Пример #18
0
 public lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage, Boolean firstIsMulti, Boolean useFirstOccurence)
 {
     lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation translation = null;
     if (Translations != null && Translations.Any(t => t.IdLanguage == idUserLanguage))
     {
         translation = Translations.Where(t => t.IdLanguage == idUserLanguage).FirstOrDefault().Translation;
     }
     if (translation == null && DefaultTranslation.IsValid() && firstIsMulti)
     {
         translation = DefaultTranslation;
     }
     if (translation == null && Translations.Any())
     {
         translation = Translations.Where(t => t.IdLanguage == idDefaultLanguage).FirstOrDefault().Translation;
     }
     if (translation == null && Translations.Any() && useFirstOccurence)
     {
         translation = Translations.FirstOrDefault().Translation;
     }
     return((translation == null) ? new lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation()
     {
         Name = Id.ToString()
     } : translation);
 }
Пример #19
0
        public bool IsTranslationUnique(TranslationEntity translationToCheck)
        {
            translationToCheck.NotNull("translationToCheck");

            return(Translations.Any(t => t.Translation == translationToCheck.Translation));
        }
Пример #20
0
 public virtual lm.Comol.Core.DomainModel.Languages.TitleDescriptionObjectTranslation GetTranslation(String userLanguageCode, Int32 idDefaultLanguage)
 {
     lm.Comol.Core.DomainModel.Languages.TitleDescriptionObjectTranslation translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? DefaultTranslation : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.LanguageCode == userLanguageCode).Select(t => t.Translation).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.Translation).FirstOrDefault();
     if (translation == null || !translation.IsValid())
     {
         translation = DefaultTranslation;
     }
     return(translation);
 }
Пример #21
0
 public virtual Boolean IsValid()
 {
     return(Translations != null && Translations.Any() && ((Channel != lm.Comol.Core.Notification.Domain.NotificationChannel.None && Channel != lm.Comol.Core.Notification.Domain.NotificationChannel.Mail) || (MailSettings != null && Channel == lm.Comol.Core.Notification.Domain.NotificationChannel.Mail)));
 }
Пример #22
0
 private bool CanClear(object arg)
 {
     return(!string.IsNullOrWhiteSpace(NewWord) || (Translations.Count > 0 && Translations.Any(x => !string.IsNullOrWhiteSpace(x.Translation))));
 }
Пример #23
0
        public virtual TitleDescriptionObjectTranslation GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage)
        {
            TitleDescriptionObjectTranslation translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? DefaultTranslation : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Select(t => t.Translation).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.Translation).FirstOrDefault();

            if (translation == null || !translation.IsValid())
            {
                translation = DefaultTranslation;
            }
            return(translation);
        }
Пример #24
0
 public lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation GetTranslation(Int32 idUserLanguage, Int32 idDefaultLanguage)
 {
     lm.Comol.Core.DomainModel.Languages.ItemObjectTranslation translation = (Translations == null || (Translations.Any() && !Translations.Where(t => t.Deleted == BaseStatusDeleted.None).Any())) ? DefaultTranslation : (Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Any()) ? Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idUserLanguage).Select(t => t.Translation).FirstOrDefault() : Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.IdLanguage == idDefaultLanguage).Select(t => t.Translation).FirstOrDefault();
     if (translation == null)
     {
         translation = DefaultTranslation;
     }
     return(translation);
 }