Override XML files

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
9/1/2012 7:15:25 AM
Gravatar
Total Posts 216
Community Expert

mojoPortal Hosting & Design @ i7MEDIA!

Override XML files

Override standard xml files

Sometimes I want to change the wording used in mojoPortal for things like the headings above the blog categories or the text chosen to go above the "comments" section.

Instead of forking my code, is it at all possible to set up an "override xml" file, that I could add into my mojoPortal root and it would override the data in the xml file that provides this text? A link to the XML file used could be added as a key in the web.config, perhaps?

I know it's possible to change the text with jQuery and even CSS (:before pseudo selector and negative text indent), but I'd rather not do jQuery because if JS is disabled it won't work and not the CSS fix for semantic reasons.

This would be useful in a lot of places for people who are particular about text content.

Thanks for all your work with mojoPortal, it's a great CMS.
-Isaac

9/3/2012 4:37:31 PM
Gravatar
Total Posts 537
feet planted firmly on the ground

Re: Override XML files

Most (all?) of the texts are already controlled by resource files, allowing mojoPortal to be translated into any language. The same approach can be used to override the default texts, though you will need to remember to put back your modified files after upgrading.

See https://www.mojoportal.com/translatingmojoportal.aspx

For example you'll find blogresources.resx in the App_GlobalResources folder.

 

9/3/2012 7:12:58 PM
Gravatar
Total Posts 216
Community Expert

mojoPortal Hosting & Design @ i7MEDIA!

Re: Override XML files

Hi Crispin,

I'm already aware of that, I've been using it to change things. What I'm asking for is the ability to include an override .resx file so that I won't have to fork the code. Basically, it would be a single file that I could change all of the text resources in and it would not be overwritten by updates, only the originals would.

This is useful because after changing the default text on 40-50 different items around the site, it gets to be quite a pain to change them back on update. It's not super-important, but I am particular about wording, and I thought perhaps other people have the same problem. =]

It would be even more awesome if this was somehow capable of being included in a skin, that way when we're designing we can change things to make them match the design a bit better. Not sure if that's possible though.

Thanks for your response,
-Isaac

9/4/2012 2:38:00 PM
Gravatar
Total Posts 18439

Re: Override XML files

Hi Guys,

The .resx files are intended for localization and I don't know of a good way to allow overriding any/all the resource strings, but I do agree that we should have a way to override some specific labels. While this could be done by editing the .resx files after each upgrade, I think for specific labels a better solution can potentially be provided on a case by case basis so I'm open to hearing about specific labels that your customers ask you to change most often.

For example in the blog we do already have a way to override the category labels (except for one I just discovered as a bug). The highlighted settings below allow these labels to be changed from theme.skin:

<blog:BlogDisplaySettings runat="server"
UseBottomNavigation="true"
UsejQueryCalendarNavigation="true"
HideCalendar="false"
HideFeedLinks="false"
HideStats="false"
BlogViewUseBottomDate="true"
BlogViewHideTopPager="false"
BlogViewHideBottomPager="false"
ArchiveViewHideFeedbackLink="false"
HideTopSideBar="false"
HideBottomSideBar="false"
OverrideListItemHeadingElement=""
OverrideCategoryLabel="Tags"
OverrideCategoryPrefixLabel="Posts Tagged in:"
OverridePostCategoriesLabel="Tagged In:"
PostListForceExcerptMode="false"
PostListForceTitleOnly="false"
PostListUseBottomDate="true"
PostListDisableContentRating="false"
DetailViewDisableContentRating="false"
UseBottomContentRating="true"
DisableShowCategories="false"
DisableShowArchives="false"
DisableShowStatistics="false"
/>

except OverrideCategoryLabel is not working in the latest release as I just discovered when looking into answering this post. I just fixed it in my copy and in the source code repository so it will be fixed in the next release.

Also note that UsejQueryCalendarNavigation is a new setting not yet in the current release but it is working in the latest code and will work in the next release. It allows using the jqueryui datepicker for the date navigation as an alternative to the asp:Calendar control used by default, so don't add that one yet unless working with the very latest code from the repository and note that enabling that may require other css changes to make the jquery calendar fit in the column without overflowing.

So rather than suggesting a technical solution like a way of overiding all the xml/resx files, instead I would rather hear which specific labels your customers are asking about the most to be able to customize and we can look into adding specific overrides for those in theme.skin.

Best,

Joe

9/4/2012 3:04:45 PM
Gravatar
Total Posts 537
feet planted firmly on the ground

Re: Override XML files

Some modules have a LOT of labels, so isn't there a danger this becomes very unwieldy? Also, how does it interact with the multi-language resource files? Does the override beat the resx, regardless of language? Can the overrides cope with multiple languages?

I'm thinking that changing labels is really the same thing as localisation... i.e. it is adapting the presentational description to use the words that best match the cultural and linguistic world view of the admins and users. So your "Tagged in:" might be my "Indexed as:". Both "en", but both legitimate localisations.

If this is valid, then could we look for a way of allowing the localisation to persist through upgrades? The skin is a good place for this as Isaac suggested.  So, could this be achieved by a setting at the site level along the lines of "Use skin-specific resource files?" = true/false.  If true, then when rendering any feature, we look into the skin folder (or a resources subfolder) for the relevant setting in the resx file, and fall back to the normal files if not found.

This would allow me to change every label in a way that survives upgrades, and works across all languages. If an upgrade adds new labels, it will still work as it will fall back to the default.

(PS I'm feeling something similar could work for email templates, which are also blown away by upgrades, and frequently need customising).

9/4/2012 3:12:56 PM
Gravatar
Total Posts 18439

Re: Override XML files

If we implement overrides it will be on a case by case basis I will not be doing it for lots and lots of labels. If you really need to change lots and lots of them then you can just keep editing those .resx files as in the past so be judicious in suggesting which labels you'd like to be able to override.

If an override is used it will not be localized it will be customized. Most people are forcing a specific language if they are creating sites for specific languages. If a site's content from  the database is in a single given language then there really is not a lot of benefit for some labels and button text to be localized so I don't see it as a big deal, its no different than database content which is not localized.

9/4/2012 5:38:38 PM
Gravatar
Total Posts 216
Community Expert

mojoPortal Hosting & Design @ i7MEDIA!

Re: Override XML files

Hey guys,

Thanks for looking into this. Joe, my idea was mostly for design purpose, and it's not especially important. I was just asking to see if an easy fix could be found, but if not I'll only change the .resx files on my site and I'll just keep a copy of them for upgrades.

The value of changing labels is small but significant in my opinion. Mostly because users are accustomed to seeing specific text in specific places - when they see a form, they're expecting some kind of "submit" button, but I don't want the wording to be that bland. So instead, I often want it to say "Proceed" or something of that sort. Or above blog comments, instead of the heading just saying "Comments", I'd like it to say "Share your mind" - something that fits with the writing style of the rest of the content on the page.

It's kind of a supplement for designs, but I think it can make a site more friendly and more unique simultaneously. Like I said, it's not extremely important though. But if you ever come up with a way to do it without forking the code, please let us know.

Thanks,
-Isaac

9/5/2012 7:45:45 AM
Gravatar
Total Posts 18439

Re: Override XML files

Hi Isaac,

The specific labels you are mentioning are all ones I would be willing to add override properties for in theme display settings.

What I'm trying to say is.

1. a way to overide any and all labels from theme.skin is not feasible

2. for a limited set of specific labels that may reflect the personality of the site I agree it would be nice to be able to override them and I'm open to those suggestions and willing to add displaysetting properties for them on a case by case basis. So for those specific labels that you feel are important to site personality, feel free to make the case for them and I will consider them on a case by case basis but it definitely is not going to be lots and lots of them from any and all features. The ones for comments do make sense but that doesn't mean that it will make sense in all features. I'd like to satisfy common needs but I'm not going to scratch every possible itch.

3. overriding is choosing customization over localization, you can't really have both and trying to achieve that would be stepping into a technical monstrosity so I'm not willing to go there especially because it doesn't really add much value to try to achieve both since the main content form the db is not localized. Its relatively easy to do it for a limited set of labels but not feasible to do it in a global way.

Best,

Joe

 

9/5/2012 8:08:33 AM
Gravatar
Total Posts 537
feet planted firmly on the ground

Re: Override XML files

Hi Joe

Is my idea above technically impossible? (i.e. it is not possible to pull in resx files from an "override" location, perhaps in the skin).

I've not tested it out, but this post perhaps suggests that the location asp.net looks for the resx files can be changed dynamically http://stackoverflow.com/questions/1649226/how-to-dynamically-load-and-switch-the-resource-file-in-the-web-app-asp-net-wi

but I don't know whether this is feasible in reality (i.e. look in the override location then falling back to the default if the resx file wan't there or didn't contain the right labels).

If it is possible somehow, then it would achieve what me and Isaac appear to want, and mean you would not have to keep adding individual labels into theme.skin overrides.

9/5/2012 9:39:22 AM
Gravatar
Total Posts 18439

Re: Override XML files

.resx files can only live in the /App_GlobalResources folder (or /App_LocalResources which we don't use in mojoPortal), there are ways around that with VirtualPathProvider but its just a lot of uneccesary overhead and complexity.

I'm not claiming its impossible to implement a global override solution I'm saying it would be overly complex and therefore not feasible enough that I'm willing to go there. It would be a big mess in my opinion and likely to lead to performance problems.

For example in that post on stackoverflow the question was about storing labels in the database. I don't want hits to the database for every label, its a bad idea. And the suggested solution is just a way to manually load a resource file from a specific location but that kind of code would require very extensive changes and have to be implemented all over the place and the example doesn't account for missing files or missing keys within files which cause null reference exceptions and basically replacing/bypassing the built in language fallback of resx files which is part of the asp.net framework and not something I want to build a replacement for. I'm not going there, it is a path to building a monstrosity. It is not worth it and not needed in my opinion. 

 

 

 

9/5/2012 10:26:01 AM
Gravatar
Total Posts 18439

Re: Override XML files

Consider that the built in localization support of the ASP.NET framework is awesome.
By storing the files in the /App_GlobalResources folder I get strongly typed objects to set my labels like this:
litHeading.Text = BlogResources.BlogCategoriesLabel;

I don't have to do anything to make it localize, by default the thread will execute as the culture specified in the browser preferred language and it will automatically choose the correct .resx file if it exists (or by config settings you can force it to execute as a specific culture), so if my browsert is set to de-DE for German and BlogResources.de.resx exists it will use that and if the key "BlogCategoriesLabel" does not exist in that file it will fall back to the default English file. I get all that for free, no hunting around the file system no checking for missing files or keys needed in my code and the key must exist in the defualt file for it to compile so errors are avoided.

Similarly there is a databinding syntax like this:
<asp:DropDownList ID="ddGMapType" runat="server" EnableTheming="false" CssClass="forminput">
<asp:ListItem Value="G_NORMAL_MAP" Text="<%$ Resources:Resource, GoogleNormalMap %>" />
<asp:ListItem Value="G_SATELLITE_MAP" Text="<%$ Resources:Resource, GoogleSatelliteMap %>" />
<asp:ListItem Value="G_HYBRID_MAP" Text="<%$ Resources:Resource, GoogleHybridMap %>" />
<asp:ListItem Value="G_PHYSICAL_MAP" Text="<%$ Resources:Resource, GoogleTerrainMap %>" />
</asp:DropDownList>

again I don't have to do anything extra to make it localize.

Now do I want to throw that away and build my own thing that I have to support? NO!!!! That would be a lot of work and a huge re-write of good solid working code.

But on a case by case basis I'm willing to do things like this:

if (displaySettings.OverrideCategoryLabel.Length > 0)
{
litHeading.Text = displaySettings.OverrideCategoryLabel;
}
else
{
litHeading.Text = BlogResources.BlogCategoriesLabel;
}

You must sign in to post in the forums. This thread is closed to new posts.