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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 27.06.2009, 10:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
mscrm4ever: CRM 4.0 Creating a JS Resource Manager
Источник: http://mscrm4ever.blogspot.com/2009/...e-manager.html
==============

The purpose of this post is to present a simple and effective way of handling multi-lingual text resources on the client (CRM) Form.

In most projects an application is built to address a single language. Knowing that from the get go simplifies the way developers weave (hard code) the application messages into each entity form.

Let’s assume, for example, that you need to validate that the account number starts with the letters “ACT ”. Your code might look like the following example:


if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)
{
alert(”Account number must begin with ACT ”);
}


This is a very simple and strait forward way to present messages to the user. However since CRM is a multi-lingual application using this approach is far from being a best practice. The reason is that your client might decide (eventually) to add another language to the system and once he does that you must rewrite you application to support the new language. Assuming you have a small amount of messages you might consider changing your code as follows:


if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)
{
if (USER_LANGUAGE_CODE == 1033) //English United States
{
alert(”Account number must begin with ACT ”);
}
else if (USER_LANGUAGE_CODE == 1043) //Dutch
{
alert(”Rekeningnummer moet beginnen met ACT ”);
}
}


Now, as long as the application stays small this solution should hold. However, applications tend to grow over time and from a certain point the amount of messages will be too overwhelming to manage in this manner.

Another reason why this approach is a bad practice is that is obligates or ties the client to an ever lasting development phase. The best approach is to shift the responsibility of handling multi-lingual tasks to the client and the best way to do that is to create a resource manager that enables you to support multi-lingual messages from your first line of code.

So how do we shift responsibility of translating our application messages to the client?
The simplest approach is to create a new text attribute for each message that you need to display. The text attribute display name can hold the message it self. For example:

New Attribute: new_msginvalidaccountnumber
Display Name: The account number must begin with “ACT “
Searchable: No
Required:No

Now, put the new attribute on the CRM form under a new tab called Labels and hide it when the form loads. E.g.


function OnCrmPageLoad()
{
document.all.tab4Tab.style.display = “none” //assuming that the fifth tab is the Labels tab.
}

OnCrmPageLoad();


Now, let’s transform the above code so it would support any language


/* --< Resource Manager >-- */
ResourceManager = function()
{
var rm = this;
rm.GetString = function( resId )
{
var resource = document.getElementById( resId );
if ( !resource )
{
/* Show missing label */
return "[" + resId + "]";
}

return crmForm.GetLabel( resource );
}
}
/* Create an instance of Resource Manager */
RM = new ResourceManager();

if (/^ACT\s{1}/.test(crmForm.accountnumber.DataValue) == false)
{
alert(RM.GetString(“new_msginvalidaccountnumber”));
}


Integrate the resource manager to each entity onload event.

Good luck…


Источник: http://mscrm4ever.blogspot.com/2009/...e-manager.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Microsoft Dynamics CRM Team Blog: Building Rich-Client Dashboards for Microsoft Dynamics CRM with Windows Presentation Foundation Blog bot Dynamics CRM: Blogs 1 31.03.2009 13:24
mscrm4ever: CRM 4.0 Public View Manager Wizard (Hiding Views) Blog bot Dynamics CRM: Blogs 1 02.03.2009 09:42
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0 Deployment Scenarios Blog bot Dynamics CRM: Blogs 0 30.01.2009 22:05
mscrm4ever: CRM 4.0 Creating Interactive Plug-ins Blog bot Dynamics CRM: Blogs 0 21.01.2009 10:05
Microsoft Dynamics CRM Team Blog: Data Migration Manager Tips and Tricks Blog bot Dynamics CRM: Blogs 0 02.09.2008 22:05
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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