How to add new text resources to resx files and troubleshooting


Adding new text resources to resx files to use in your custom views is supported by all versions of Safewhere Identify.  A good tool to use for editing is the Zeta Resource Editor tool. We find that the guideline at https://github.com/UweKeim/ZetaResourceEditor is very useful.

Here is the sample that I used for my local environment: I add a new text key: UserNamePasswordUserNameLabel to  the UserNamePasswordResources files (“neutral”, da,  en):

Screenshot_29

How to use the new key

After adding the new key, it is ready for using on both Razer views (aka cshtml views) and hosted forms. However, sometimes a mistake can happen somewhere that causes the new text resource not showing up the views. The following steps will help you check if everything is done correctly.

1. Your keys are added to the correct text resource files

If your environment uses redundant setup, your newly added keys must present on all text resource files on all servers. For example, if your environment has two Identify web servers, you can go to the C:\Program Files\Safewhere\Identify\Tenants\[yourtenant]\runtime\App_GlobalResources folders on both servers and verify if the UserNamePasswordResources.[language code].resx files contain the keys. It is always a good idea to open the files to double check if your new keys are there.

2. Check if you are using the new keys for the correct views

Identify offers several ways to customize a view:

  1. By editing a cshtml view file directly.
  2. By using hosted form. The section “The list of supported hosted forms” has a list Razor views with their respective hosted form names.
  3. By specifying a custom cshtml file to use for a functionality.

A common mistake is when you apply the new text resource key to, for example, a Razor view file when your Identify instance is using the other view types.

In this post, we are going to use the UserNamePasswordAuthentication view as an example. By default, its Razor view file is in the \Tenants\[your tenant]\runtime\views\plugin folder. However, if you have enabled hosted form for it, the hosted form view will be used. When that is the case, when you access the Field configurations list using Identify Admin, you can see a record whose prefix name is “CustomContent|UserNamePasswordAuthentication” and its “Resource Key” is “Html”:

Screenshot_32

This means that your Identify instance is using this hosted form view to render the login page instead of the Razor view. A trick to check if your instance is using the Razor view or the hosted form view is edit some random text on both views and do a login to see which on is used. Please note that you may need to wait some minutes after updating a hosted form view before the change takes effect. Meanwhile, you either need to edit the Razor views on all servers or do the test on a server itself. If you changes don’t reflect on both cases, maybe you need to check if a custom Razor view is in use.

Anyway, the new text resource keys should be applied to the views that your Identify instance is using.

3. Apply your new key the correct way

  1. If the razor view is used for the login flow, e.g the UserNamePasswordAuthentication.cshtml, you can use your new key like below:

Syntax:

Use in Razor view:

Screenshot_24

and here is the result when I use a browser set to Danish language:

Screenshot_31

Note: if your environment uses redundant setup, you must update all razor files on all Identify web servers.

  1. If the hosted form view is used, you can add your key like below:

Syntax:

Liquid view:

Screenshot_26

and here is the result when I use a browser set to Danish language:

Screenshot_30

You can find more details about how to use text resources on hosted forms at http://docs.safewhere.com/identify-how-to-use-text-resource-on-html-template-on-safewhere-admin/

 4. Other cases

If you have checked all the above and your text display doesn’t show as expect, please try:

  • Use the reflector tool to access the dll compiled resources, e.g App_GlobalResources.f9dqnyk6.resources.dll at folder:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\runtime. As this contains a lot of folders there, you can take a look at its latest date modified to select the right folder. Here is my sample:

Screenshot_28