Anyone who has worked on a larger Optimizely solution will know the feeling. You add or update a page type, block type, or shared base class, and then need to keep the language resource XML in sync. It is not difficult work, but it is repetitive, easy to miss, and becomes more painful as the number of content types grows.
This started as a small pet project for my own convenience. I wanted a quick way to generate a starting point for Optimizely language resource files directly from the content type code already in a project. Once it was useful in day-to-day work, I thought it could also benefit the wider Optimizely community if I packaged it properly and made it publicly available.
That is where Optimizely XML Resource Builder came from.
What it does
Optimizely XML Resource Builder is a Visual Studio extension that scans the project you select and generates an Optimizely language resource file from its C# content type definitions.
It reads content type attributes such as ContentType and SiteContentType, then creates the XML entries for the content type name, description, properties, captions, and help text.
The default output is:
Resources\Translations\ContentTypes-en.xml
You can change both the language code and output folder from the extension dialog.
Why I built it
Language resource files are useful for keeping the Optimizely editor UI clean and consistent, especially when you are working across several languages. The challenge is that the information is usually already present in code:
[ContentType(DisplayName = "Article Page")]
public class ArticlePage : SitePageData
{
[Display(Name = "Heading", Description = "The main page heading")]
public virtual string Heading { get; set; }
}
Copying those values into XML by hand adds another maintenance step. The extension uses the information already available in the attributes and gives you a generated file to review, commit, and translate.
Key features
- Project-level command: right-click an Optimizely project in Solution Explorer to generate the resource XML.
- Flexible content type detection: scan for
SiteContentType,ContentType, or any additional attributes you configure. - Configurable generation dialog: choose a comma-separated attribute list, language code, excluded property prefixes, and output folder before generating the file.
- Caption casing control: keep the original display-name case or convert captions to sentence case while preserving uppercase acronyms.
- Overwrite control: choose whether to replace the existing XML file or safely add only missing entries.
- Useful XML generated from code: create content type names, descriptions, property captions, and help text from the attributes already defined in C#.
- Shared base-class support: find properties on custom base classes and add them under
icontentdata. - Safe updates: add only missing XML entries by default, preserving existing translations and custom values. Enable overwrite only when you want a fresh file.
- Solution-specific preferences: save settings per solution, rather than using one global set of values across every project.
How to use it
- Install the extension.
- Open an Optimizely solution in Visual Studio.
- In Solution Explorer, right-click the project that contains the content type classes.
- Select Build Optimizely XML Resource File.
- Set the attribute list, language code, output folder, and any exclusions.
- Select OK.
If no matching content types are found, the extension shows a warning and does not create an empty XML file.
Example output
<contenttypes>
<icontentdata>
<properties>
<metadescription>
<caption>Meta description</caption>
</metadescription>
</properties>
</icontentdata>
<articlepage>
<name>Article Page</name>
<properties>
<heading>
<caption>Heading</caption>
<help>The main page heading</help>
</heading>
</properties>
</articlepage>
</contenttypes>
Compatibility
The extension supports Visual Studio 2022 and later.
Links
- GitHub repository: OptiXMLResourceBuilder
- Visual Studio Marketplace: search for Optimizely XML Resource Builder or https://marketplace.visualstudio.com/items?itemName=adnanzameer.OptiXMLResourceBuilder
I hope it saves other Optimizely developers the same repetitive work it saves me. If you try it, feedback and contributions are very welcome.



0 comments :
Post a Comment