We recently had a client request that a page property have a different display name for each language branch. The function of the property was as an identifier and would always be used the same in the back end but the editors in each country had a different name for the property.
This isn't a particularly inspired solution, but I'm hoping to save someone else the time it took to stumble upon this.
It is possible to localize EPi property names using the built in Display attribute and keeping the translations in resources files (see this stackoverflow post here), but this is only based on the UI language in Edit/Admin mode and not on content language.
I created an EditorDescriptor
that will take the string entered in the Name field and try to translate it using the registered LocalizationService (whatever that may be). An important thing to note is the EditorDescriptorBehavior
. We have to have it as EditorDescriptorBehavior.PlaceLast
to ensure that any other logic to get the Display Name (built in translation, etc) does not interfere with what we want displayed.
Code
[EditorDescriptorRegistration(TargetType = typeof(String), UIHint = SiteUIHints.LocalizedDisplay, EditorDescriptorBehavior = EditorDescriptorBehavior.PlaceLast)]
public class LocalizableDisplayEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
Attribute attr = attributes.FirstOrDefault(a => a.GetType() == typeof(DisplayAttribute));
if (attr != null)
{
string translated =
ServiceLocator.Current.GetInstance<LocalizationService().GetStringByCulture(metadata.DisplayName,
FallbackBehaviors.None, ContentLanguage.PreferredCulture);
if (!string.IsNullOrWhiteSpace(translated))
metadata.DisplayName = translated;
}
}
}
Usage
[UIHint(SiteUIHints.LocalizedDisplay)]
[Display(Name = "/properties/InternalId/displayname", Order = 200)]
public virtual string InternalId { get; set; }
Howdy. Very nice web site!! Guy .. Excellent .. Superb .. I will bookmark this site and take the feeds additionally…I am glad to find a lot of helpful info here within the article. Thank you for sharing… Boulevard 88 Price
ReplyDeleteGreat Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot. villa for sale Nagueles
ReplyDeleteExcellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Riviere Jiak Kim Street
ReplyDeleteMmm.. good to be here in your article or post, whatever, I think I should also work hard for my own website like I see some good and updated working in your site. House blog
ReplyDeleteYou have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site. General Contractor Maryland
ReplyDeleteI got what you mean, thanksfor posting .Woh I am happyto find this website through google. Las Colinas Properties For Sale
ReplyDeleteHiya, I am really glad I have found this information. Today bloggers publish just about gossips and web and this is really annoying. A good web site with interesting content, that’s what I need. Thanks for keeping this site, I’ll be visiting it. Do you do newsletters? Can’t find it. apartemen jakarta selatan
ReplyDeleteThank you for taking the time to publish this information very useful! Kopar at Newton
ReplyDeleteThe next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to read, but I actually thought you have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention. Assertiveness Training Brisbane
ReplyDeleteI was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. Costa Del Sol Property For Sale
ReplyDeleteAlgarve Property For Sale When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your.
ReplyDeletenature is definately not expensive. go on a hike with friends, or just explore a forest. there are always creeks to walk thru and all kinds of colorful plants and flowers. even frisbee golf is fun, free, and good exercise best real estate agency manila
ReplyDeleteExcellent! I thank you your contribution to this matter. It has been insightful. warehouse to let
ReplyDeleteOn the off chance that you see this documentation and consider in the evaluating cycle for the property, it is insightful to consider the genuine freedom of the valuation when it was done and its significance to the current market. https://yes-mallorca-property.com
ReplyDeleteIs the property in good condition and is it in a good location? These should be crucial considerations, as you will either want to let the property, or sell it to another property investor or home-buyer. property wealth advisor
ReplyDeleteOur profit for this speculation will be driven by two essential factors: our rental salary and the energy about the property estimation. Along these lines, we should start by determining rental salary and the valuation for the property in thought. https://yes-mallorca-property.com/information/faq/general-issues/
ReplyDeleteA Property Advisor works for a business building administration organization to oversee and give office upkeep and fixes, parking garage fixes and clearing administrations, pressure washing and hydro-cleaning, mass garbage evacuation and business painting while keeping the you, the customer, exceptional through the whole cycle and guaranteeing fulfillment investment property advice
ReplyDeleteCastle hill has many caves, connected together during the Turkish occupation for military use, and these seen through guided tours. budapest rental
ReplyDeleteit has a frame with different sections or levels allowing more than one (usually two) person to sleep. The individual frames are stacked one on top of the other. If the room has limited floor space then these are a must have. You generally find these in ship cabins, army dormitories, hostels, army garrisons, summer campsites, universities, jails etc. bed with slide
ReplyDeleteThey define your floor plan, divvying up the footprint of your space into multiple rooms. Walls Apartment For Rent In Hcmc support artwork, bookshelves coat hooks, mirrors, and lighting
ReplyDeleteHowdy! This article could not be written any better! Going through this article reminds me of my previous roommate! He celebrity homes continually kept preaching about this.
ReplyDelete