DictionaryBuilder is an unofficial Visual Studio extension for generating a strongly typed dictionary service and models for Umbraco.
[Visual Studio Versions:]
-
Community Edition 2019 V16.9.2
[Umbraco Versions:]
-
8.11.1
* The extension may work with other versions of Visual Studio and Umbraco but has not been officially tested meaning that undesired results may occur. This list will be maintained as more testing is undertaken.
- Clone the repository.
- Open in Visual Studio.
- Build the solution.
- In Windows Explorer, navigate to \DictionaryBuilder\bin\{Debug/Release} in your solution's folder.
- Locate and install DictionaryBuilder.vsix.
- Extension options can be configured in Visual Studio by navigating to:
Tools > Options > Umbraco > DictionaryBuilder Options:
- A complete list of user preferences with the default option values and example SQL connection data can be viewed below (more information about each setting is shown below the property grid when highlighting an option):
- The options file is saved in the same location as the solution using the naming convention:
<solution name>.UmbracoDictionary.user
. SQL passwords are encrypted using a System Key or Common Key as defined by the Encryption Method setting (see above screenshot) allowing you to commit this file into your repository.
- The contents of the file is serialised using XML e.g.
- An Umbraco Dictionary context menu is available when right clicking on any project within the Solution Explorer. Click on the Rebuild Dictionary command to export the latest version of the dictionary models along with a service, extension classes and interfaces etc:
- The exported files will be written to the paths defined in the extension options e.g:
- Progress is written to the output window along with any error messages:
- An example of the source code generated by the DictionaryBuilder can be found in this repository folder: Example Code.
- The example code is based on the following Umbraco dictionary structure which contains event messages to alert a content editor if they attempt to delete a node where this action has been disabled for their access level:
- When the content editor attempts to delete a configuration node e.g:
- An alert is shown to the content editor. In this case the alert message is retrieved from the Umbraco dictionary using the exported DictionaryBuilder service and strongly typed class models:
- Example source code usage (for the full example see the commented source code in ExampleUsage.cs):
- It is possible to synchronise the dictionary database tables between development, staging and live deployments.
IMPORTANT: It is strongly recommended to backup the destination database before doing so. The language table is not synchronised and it is therefore suggested that you check that the languages and id's match between deployments - otherwise dictionary values may be assigned to the wrong language after synchronising:
- You will be prompted to confirm your selection before the synchronisation begins:
- Progress is written to the output window along with any error messages: