Custom Type Localization

Topics: Localization
Mar 1, 2013 at 10:57 AM
i have a custom type:
SchemaBuilder.CreateTable(
                "OfficeRecord",
                table =>
                table.ContentPartRecord()
                     .Column("Region", DbType.String)
                     .Column("City", DbType.String));
ContentDefinitionManager.AlterTypeDefinition("Office", cfg => cfg.WithPart("OfficePart"));
ContentDefinitionManager.AlterTypeDefinition("Office", type => type.WithPart("LocalizationPart").WithPart("CommonPart").Creatable());
now i can add translation in admin menu.
how i may select from database( using content manager or whatelse) only Offices with
current selected site Culture
this.cultureManager.GetCurrentCulture(this.HttpContext);
?
Developer
Mar 2, 2013 at 10:01 AM
Something like this:
var culture = this.cultureManager.GetCurrentCulture(this.HttpContext);
var offices = _contentManager.Query<OfficePart, OfficeRecord>().Join<LocalizationPartRecord>().Where(x => x.CultureId == culture.Id).ToList();
Mar 4, 2013 at 3:34 AM
this ok, but when i'm
using Orchard.Localization;
my module doesnot know about Orchard.Localization.Models, where declared LocalizationPartRecord. and VS wrote to me "cannot resolve symbol 'Models'"
why?
in Orchard.Localization module available to my module only:
Orchard.Localization.Services
Orchard.Localization.Commands
Orchard.Localization.Records
 using Orchard.Localization;
 using Orchard.Localization.Models; // there is error :(
 using Orchard.Localization.Services;
 public class OfficeListService : IOfficeListService
    {
        private readonly IContentManager contentManager;
        private readonly ICultureManager cultureManager;
        public OfficeListService(IContentManager contentManager, ICultureManager cultureManager)
        {
            this.contentManager = contentManager;
            this.cultureManager = cultureManager;
        }
public IEnumerable<OfficePart> Get(string region, bool cash, bool conn, string culture)
        {
            var cultureRecord = this.cultureManager.GetCultureByName(culture);
            var t =
                this.contentManager.Query<OfficePart, OfficeRecord>(VersionOptions.Latest)
                .Where(off =>
                        (off.Region == region || region == "ВСЕ") && (!cash || off.CashOffice == cash)
                        && (!conn || off.Connection == conn))
                        .Join<LocalizationPartRecord>().Where(x => x.CultureId == cultureRecord.Id)   //and there LocalizationPartRecord - unknown type :(
                    .List();
            return t;
        }
}
Mar 4, 2013 at 4:04 AM
got the win with:
separate compilation of Orchard.Localization and then adding the reference to Orchard.Localization.dll in my module
if possible as that in another, write :)
Developer
Mar 4, 2013 at 9:49 AM
I guess that works too. I usually just add a project reference.