This project is read-only.

Custom Type Localization

Topics: Localization
Mar 1, 2013 at 10:57 AM
i have a custom type:
                table =>
                     .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
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'"
in Orchard.Localization module available to my module only:
 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 :(
            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 :)
Mar 4, 2013 at 9:49 AM
I guess that works too. I usually just add a project reference.