How to setup and use custom database text resources 

Introduction

This short document is considered as a user guideline on how to setup and use the new feature “database-based text resources” for the Identify runtime views.

Concepts

  1. Container

A container is a bag of text resources categorized for using in a specific area. In file-based text resources, a container is considered as a Resx file such as RuntimeModelResources, UserNamePasswordResources.

A container can go with a specific language or a default one without language suffix. To specify a language for a container, a 2 letters ISO language code must be use. For example: RuntimeModelResources.da.

In database-based text resources, a container can be an existing text resource file name or a GlobalTextResources name. 

  1. GlobalTextResources container

The global container that can be used in Razor view with a user-friendly syntax (ref the Usage section for more detail)

Note that both Container name, Language code and Resource Key as Case-Insensitive while working with REST API and Using text resources.

Setup

Currently we only provide some REST API endpoints to allow the user to setup custom database text resources.

In this section, the Swagger is used to introduce and guide all API to setup the custom text resources: 

Add a text resource 

image3

Add multiple text resources 

image4

Add a text resource container 

image5

Import text resource from resx file 

image6

Delete a text resource 

image7

Delete a text resource container 

image8

Usage

Let's say that we had created a GlobalTextResources container with a new text resource named “NewTextResource” by using the above REST API. Below is the usage guideline for both Razor and Hosted form view engine: 

Razor views 

For a Razor view, we have 2 cases of using the database text resource: GlobalTextResources and another specific name container. 

  1. GlobalTextResources container 

Syntax: @Resources.GlobalTextResources.Text["TextResourceKey"] 

Example: @Resources.GlobalTextResources.Text["NewTextResource"] 

  1. Other containers 

For a container with the name is different from “GlobalTextResources”, the fully qualified name should be used to display the text resource.  

Syntax: @Resources.GlobalTextResources.Text["ContainerName.TextResourceKey"] 

Example: @Resources.GlobalTextResources.Text["RuntimeModelResources.TextResourceKey"] 

Warning: Although it is possible to create containers with any names that you like, we strongly recommend that you put all of your custom text resource keys into the GlobalTextResources container. We will remove the ability to create containers with arbitrary in a near future version.

Hosted forms 

In hosted forms, the database text resources can be used as the same way as the file-based text resources. To display a text resource, we still use the

syntax: {{Resources.ContainerName.TextResourceKey}} 

For example: 

{{Resources.RuntimeModelResources.TextResourceKey}} 

{{Resources.GlobalTextResources.NewTextResource}}