AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.03.2018, 23:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
powerobjects: Searching Custom Web Resource Content Blog bot Dynamics CRM: Blogs 0 03.01.2018 20:12
crminthefield: Building Multi-Purpose Silverlight Web Resources in Dynamics CRM 2011 Blog bot Dynamics CRM: Blogs 0 28.01.2012 02:16
Microsoft Dynamics CRM Team Blog: Web Resources Generated During Upgrades: Don't Ship Them! Blog bot Dynamics CRM: Blogs 0 08.08.2011 23:11
Inside Dynamics AX 4.0: The Web Framework Blog bot DAX Blogs 0 25.10.2007 03:04
Pokluda: Outbound web service (AIF) Blog bot DAX Blogs 0 28.10.2006 17:43
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:15.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.