![]() |
#1 |
Участник
|
powerobjects: Language Localized Web Resources
Источник: https://www.powerobjects.com/2018/03...web-resources/
============== ![]() One of the lesser-known features in Dynamics 365 v9.0 is the ability to include localized strings in web resources. In the past, developers resorted to coming up with their own ways to handle this. This usually involved code to determine the current language and then hardcoding strings directly in the JavaScript or storing values in XML files or entities and writing more code to retrieve values themselves. Now using resource files (RESX) and a new JavaScript method you can store the values in a structured manner and use a single line of code to retrieve the correct value. When creating the resource files for each language there are few points that need to be remembered. In the web resource, you’ll need to include the numeric language code in the Name as well as specify the Language type in the Content settings. In this example, 1033 is English and 1036 is French. Also, make sure the key is the same in each file – example “Greeting.” In this example, Visual Studio is being used to create the RESX files but under the hood, they are just XML files. The schema is a bit complex so if possible use a tool to create them rather than doing it manually. ![]() ![]() In order to get a localized value from one of these files you can use the new “Xrm.Utility.getResourceString” method. The first parameter is the first part of the web resource Name including the prefix. The second is the key from the RESX file. The specific language is not defined anywhere. The result will come from the RESX file that matches the logged in user’s default language. If it doesn’t exist, it will fall back to the organization’s base language. ![]() The last important piece that needs to be done is to associate the RESX files you might need with the JavaScript web resource. This ensures that when the JavaScript file is loaded it will also load any other associated web resources without needing to add them directly to any forms that might require them. ![]() Once the setup is complete, you can bind scripts to form events as you normally would. The resulting alert displays the value based on the logged in user’s language selection with is found under the user options. When the language is set to English, the result comes from the English RESX file. When the language is set to French, the result comes from the French RESX file. ![]() There you have it! For more helpful Dynamics 365 tips and tricks check out our blog. Happy Dynamics 365’ing! Источник: https://www.powerobjects.com/2018/03...web-resources/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|