Пример #1
0
        protected virtual string GetExpressionName(ExpressionInfo ei)
        {
            if (ei.Property.Name == "Parent")
            {
                return("Children");
            }

            if (ei.IsUnique)
            {
                return(Reflector.CleanTypeName(ei.ToType));
            }

            return(NaturalLanguageTools.Pluralize(Reflector.CleanTypeName(ei.ToType).SpacePascal()).ToPascal());
        }
Пример #2
0
        public JsonNetResult PluralAndGender()
        {
            string name = Request.Form["name"];

            CultureInfo ci = CultureInfo.GetCultureInfo(regex.Match(name).Groups["lang"].Value);

            string text = Request.Form["text"];

            return(this.JsonNet(new
            {
                gender = NaturalLanguageTools.GetGender(text, ci),
                plural = NaturalLanguageTools.Pluralize(text, ci)
            }));
        }
Пример #3
0
        internal static LocalizedType ImportXml(Type type, DescriptionOptions opts, LocalizedAssembly assembly, XElement x)
        {
            string?description = !opts.IsSetAssert(DescriptionOptions.Description, type) ? null :
                                 (x == null || x.Attribute("Name").Value != type.Name ? null : x.Attribute("Description")?.Value) ??
                                 (!assembly.IsDefault ? null : DescriptionManager.DefaultTypeDescription(type));

            var xMembers = x?.Elements("Member")
                           .Select(m => KeyValuePair.Create(m.Attribute("Name").Value, m.Attribute("Description").Value))
                           .Distinct(m => m.Key)
                           .ToDictionary();

            LocalizedType result = new LocalizedType
            {
                Type     = type,
                Options  = opts,
                Assembly = assembly,

                Description       = description,
                PluralDescription = !opts.IsSetAssert(DescriptionOptions.PluralDescription, type) ? null :
                                    ((x == null || x.Attribute("Name").Value != type.Name ? null : x.Attribute("PluralDescription")?.Value) ??
                                     (!assembly.IsDefault ? null : type.GetCustomAttribute <PluralDescriptionAttribute>()?.PluralDescription) ??
                                     (description == null ? null : NaturalLanguageTools.Pluralize(description, assembly.Culture))),

                Gender = !opts.IsSetAssert(DescriptionOptions.Gender, type) ? null :
                         ((x?.Attribute("Gender")?.Value.Single()) ??
                          (!assembly.IsDefault ? null : type.GetCustomAttribute <GenderAttribute>()?.Gender) ??
                          (description == null ? null : NaturalLanguageTools.GetGender(description, assembly.Culture))),

                Members = !opts.IsSetAssert(DescriptionOptions.Members, type) ? null :
                          (from m in GetMembers(type)
                           where DescriptionManager.OnShouldLocalizeMember(m)
                           let value = xMembers?.TryGetC(m.Name) ?? (!assembly.IsDefault ? null : DescriptionManager.DefaultMemberDescription(m))
                                       where value != null
                                       select KeyValuePair.Create(m.Name, value))
                          .ToDictionary()
            };

            return(result);
        }
Пример #4
0
 public string Pluralize(string culture, [Required, FromBody] string text)
 {
     return(NaturalLanguageTools.Pluralize(text, CultureInfo.GetCultureInfo(culture)));
 }
Пример #5
0
 protected virtual string GetFieldMListName(DiffTable table, DiffTable relatedTable, MListInfo mListInfo)
 {
     return(NaturalLanguageTools.Pluralize(relatedTable.Name.Name.RemovePrefix(table.Name.Name)));
 }
        protected virtual string GetFieldMListName(DiffTable table, DiffTable relatedTable, MListInfo mListInfo)
        {
            ObjectName name = mListInfo.TrivialElementColumn?.ForeignKey.TargetTable ?? relatedTable.Name;

            return NaturalLanguageTools.Pluralize(GetEntityName(name).RemoveSuffix("Entity")).FirstLower();
        }