<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Using Language Resources</title><link>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Using Language Resources</title><link>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources</link><pubDate>Wed, 05 Aug 2020 16:18:24 GMT</pubDate><guid isPermaLink="false">efb7a744-38e7-4bbb-a26b-a66c6c702b12</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources#comments</comments><description>Current Revision posted to Developer Training by Former Member on 08/05/2020 16:18:24&lt;br /&gt;
&lt;p&gt;Widgets support using language resources to provide separation of the text displayed in a widget and its implementation and provide support for multiple languages&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi0"&gt;&lt;a id="Creating_Resources" name="Creating_Resources"&gt;&lt;/a&gt;Creating Resources&lt;/h2&gt;
&lt;p&gt;In Widget Studio, each widget has link to its language resources. On this page, a widget&amp;#39;s resources can be viewed and edited. If multiple languages are enabled on the site, selecting the language in the drop down will allow editing of resources for that language.&amp;nbsp; Additional resources for [[Working with Widget Studio]] are available to provide a basic overview of editing widgets.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/750x350/__key/communityserver-wikis-components-files/00-00-00-12-83/AddingResources.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi1"&gt;&lt;a id="Using_Language_Resources" name="Using_Language_Resources"&gt;&lt;/a&gt;Using Language Resources&lt;/h2&gt;
&lt;h3 id="mcetoc_1dfe5ah030"&gt;&lt;a id="To_define_a_widget_property" name="To_define_a_widget_property"&gt;&lt;/a&gt;To define a widget property&lt;/h3&gt;
&lt;p&gt;A resource can be used to define the Name or Description of a widget using the following syntax.&amp;nbsp; If a widget had a resource named &lt;em&gt;HelloWorld&lt;/em&gt;.&amp;nbsp; That resource could be used for the name of the widget&amp;nbsp;by setting the name field to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;${resource:HelloWorld}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5cfhj1"&gt;&lt;a id="To_display_text_in_a_widget" name="To_display_text_in_a_widget"&gt;&lt;/a&gt;To display text in a widget&lt;/h3&gt;
&lt;p&gt;Resources can also be used directly in widget script.&amp;nbsp; The same&amp;nbsp;&lt;em&gt;HelloWorld&lt;/em&gt; resource could be&amp;nbsp;referenced in script as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_language.GetResource(&amp;quot;HelloWorld&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Additionally language resources can be used to for formatted strings.&amp;nbsp; This can be particularly useful when supporting multiple languages where the structure of a phrase may differ between languages.&amp;nbsp; For example, you could have a resource with the string value {0}:{1} in one language and {1}:{0} in another language.&amp;nbsp; The same code below would&amp;nbsp;result in the two passed in values being in different order in the two languages.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$core_v2_language.FormatString($core_v2_language.GetResource(&amp;quot;ValueWithFormatting&amp;quot;), $core_v2_group.Current.Name, $core_v2_application.Current.HtmlName(&amp;quot;web&amp;quot;))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5gvkd2"&gt;&lt;a id="Passing_a_resource_into_a_widget_s_JavaScript_files" name="Passing_a_resource_into_a_widget_s_JavaScript_files"&gt;&lt;/a&gt;From a JavaScript file&lt;/h3&gt;
&lt;p&gt;In some instances, it may be necessary to access a widget&amp;#39;s language resources while executing JavaScript.&amp;nbsp; In this instance, the resource values can be passed into the JavaScript register method and then referenced by the defined variable. It is important to JavaScript encode your resources in this instance, certain characters that could be present in resources will cause JavaScript errors.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;#registerEndOfPageHtml(&amp;#39;telligent.evolution.widgets.helloworld&amp;#39;)
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl(&amp;quot;ui.js&amp;quot;))&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
#end
#registerEndOfPageHtml()
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
		jQuery(function(){
			jQuery.telligent.evolution.widgets.helloworld.register({
				resourceText: &amp;#39;$core_v2_encoding.JavascriptEncode($core_v2_language.GetResource(&amp;quot;FromJavascript&amp;quot;))&amp;#39;
			});
		});
	&amp;lt;/script&amp;gt;
#end&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then in the JavaScript file, the resource can be retrieved using the name that was provided to the register method.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="javascript"&gt;(function($)
{
	if (typeof $.telligent === &amp;#39;undefined&amp;#39;) { $.telligent = {}; }
	if (typeof $.telligent.evolution === &amp;#39;undefined&amp;#39;) { $.telligent.evolution = {}; }
	if (typeof $.telligent.evolution.widgets === &amp;#39;undefined&amp;#39;) { $.telligent.evolution.widgets = {}; }

	$.telligent.evolution.widgets.helloworld =
	{
		register: function(context)
		{
            alert(context.resourceText);
		}
	};
})(jQuery);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: translations, localizations, Language Resources&lt;/div&gt;
</description></item><item><title>Using Language Resources</title><link>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources/revision/4</link><pubDate>Thu, 11 Jul 2019 03:38:04 GMT</pubDate><guid isPermaLink="false">efb7a744-38e7-4bbb-a26b-a66c6c702b12</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources#comments</comments><description>Revision 4 posted to Developer Training by Former Member on 07/11/2019 03:38:04&lt;br /&gt;
&lt;p&gt;Widgets support using language resources to provide separation of the text displayed in a widget and its implementation and provide support for multiple languages&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi0"&gt;&lt;a id="Creating_Resources" name="Creating_Resources"&gt;&lt;/a&gt;Creating Resources&lt;/h2&gt;
&lt;p&gt;In Widget Studio, each widget has link to its language resources. On this page, a widget&amp;#39;s resources can be viewed and edited. If multiple languages are enabled on the site, selecting the language in the drop down will allow editing of resources for that language.&amp;nbsp; Additional resources for [[Working with Widget Studio]] are available to provide a basic overview of editing widgets.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/750x350/__key/communityserver-wikis-components-files/00-00-00-12-83/AddingResources.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi1"&gt;&lt;a id="Using_Language_Resources" name="Using_Language_Resources"&gt;&lt;/a&gt;Using Language Resources&lt;/h2&gt;
&lt;h3 id="mcetoc_1dfe5ah030"&gt;&lt;a id="To_define_a_widget_property" name="To_define_a_widget_property"&gt;&lt;/a&gt;To define a widget property&lt;/h3&gt;
&lt;p&gt;A resource can be used to define the Name or Description of a widget using the following syntax.&amp;nbsp; If a widget had a resource named &lt;em&gt;HelloWorld&lt;/em&gt;.&amp;nbsp; That resource could be used for the name of the widget&amp;nbsp;by setting the name field to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;${resource:HelloWorld}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5cfhj1"&gt;&lt;a id="To_display_text_in_a_widget" name="To_display_text_in_a_widget"&gt;&lt;/a&gt;To display text in a widget&lt;/h3&gt;
&lt;p&gt;Resources can also be used directly in widget script.&amp;nbsp; The same&amp;nbsp;&lt;em&gt;HelloWorld&lt;/em&gt; resource could be&amp;nbsp;referenced in script as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_language.GetResource(&amp;quot;HelloWorld&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Additionally language resources can be used to for formatted strings.&amp;nbsp; This can be particularly useful when supporting multiple languages where the structure of a phrase may differ between languages.&amp;nbsp; For example, you could have a resource with the string value {0}:{1} in one language and {1}:{0} in another language.&amp;nbsp; The same code below would&amp;nbsp;result in the two passed in values being in different order in the two languages.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$core_v2_language.FormatString($core_v2_language.GetResource(&amp;quot;ValueWithFormatting&amp;quot;), $core_v2_group.Current.Name, $core_v2_application.Current.HtmlName(&amp;quot;web&amp;quot;))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5gvkd2"&gt;&lt;a id="Passing_a_resource_into_a_widget_s_JavaScript_files" name="Passing_a_resource_into_a_widget_s_JavaScript_files"&gt;&lt;/a&gt;From a JavaScript file&lt;/h3&gt;
&lt;p&gt;In some instances, it may be necessary to access a widget&amp;#39;s language resources while executing JavaScript.&amp;nbsp; In this instance, the resource values can be passed into the JavaScript register method and then referenced by the defined variable. It is important to JavaScript encode your resources in this instance, certain characters that could be present in resources will cause JavaScript errors.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;#registerEndOfPageHtml(&amp;#39;telligent.evolution.widgets.helloworld&amp;#39;)
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl(&amp;quot;ui.js&amp;quot;))&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
#end
#registerEndOfPageHtml()
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
		jQuery(function(){
			jQuery.telligent.evolution.widgets.helloworld.register({
				resourceText: &amp;#39;$core_v2_encoding.JavascriptEncode($core_v2_language.GetResource(&amp;quot;FromJavascript&amp;quot;))&amp;#39;
			});
		});
	&amp;lt;/script&amp;gt;
#end&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then in the JavaScript file, the resource can be retrieved using the name that was provided to the register method.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="javascript"&gt;(function($)
{
	if (typeof $.telligent === &amp;#39;undefined&amp;#39;) { $.telligent = {}; }
	if (typeof $.telligent.evolution === &amp;#39;undefined&amp;#39;) { $.telligent.evolution = {}; }
	if (typeof $.telligent.evolution.widgets === &amp;#39;undefined&amp;#39;) { $.telligent.evolution.widgets = {}; }

	$.telligent.evolution.widgets.helloworld =
	{
		register: function(context)
		{
            alert(context.resourceText);
		}
	};
})(jQuery);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item><item><title>Using Language Resources</title><link>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources/revision/3</link><pubDate>Thu, 11 Jul 2019 03:36:56 GMT</pubDate><guid isPermaLink="false">efb7a744-38e7-4bbb-a26b-a66c6c702b12</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/67245/using-language-resources#comments</comments><description>Revision 3 posted to Developer Training by Former Member on 07/11/2019 03:36:56&lt;br /&gt;
&lt;p&gt;Widgets support using language resources to provide separation of the text displayed in a widget and its implementation and provide support for multiple languages&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi0"&gt;&lt;a id="Creating_Resources" name="Creating_Resources"&gt;&lt;/a&gt;Creating Resources&lt;/h2&gt;
&lt;p&gt;In Widget Studio, each widget has link to its language resources. On this page, a widget&amp;#39;s resources can be viewed and edited. If multiple languages are enabled on the site, selecting the language in the drop down will allow editing of resources for that language.&amp;nbsp; Additional resources for [[Working with Widget Studio]] are available to provide a basic overview of editing widgets.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/750x350/__key/communityserver-wikis-components-files/00-00-00-12-83/AddingResources.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1dfe4fkdi1"&gt;&lt;a id="Using_Language_Resources" name="Using_Language_Resources"&gt;&lt;/a&gt;Using Language Resources&lt;/h2&gt;
&lt;h3 id="mcetoc_1dfe5ah030"&gt;&lt;a id="To_define_a_widget_property" name="To_define_a_widget_property"&gt;&lt;/a&gt;To define a widget property&lt;/h3&gt;
&lt;p&gt;A resource can be used to define the Name or Description of a widget using the following syntax.&amp;nbsp; If a widget had a resource named &lt;em&gt;HelloWorld&lt;/em&gt;.&amp;nbsp; That resource could be used for the name of the widget&amp;nbsp;by setting the name field to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;${resource:HelloWorld}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5cfhj1"&gt;&lt;a id="To_display_text_in_a_widget" name="To_display_text_in_a_widget"&gt;&lt;/a&gt;To display text in a widget&lt;/h3&gt;
&lt;p&gt;Resources can also be used directly in widget script.&amp;nbsp; The same&amp;nbsp;&lt;em&gt;HelloWorld&lt;/em&gt; resource could be&amp;nbsp;referenced in script as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;$core_v2_language.GetResource(&amp;quot;HelloWorld&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Additionally language resources can be used to for formatted strings.&amp;nbsp; This can be particularly useful when supporting multiple languages where the structure of a phrase may differ between languages.&amp;nbsp; For example, you could have a resource with the string value {0}:{1} in one language and {1}:{0} in another language.&amp;nbsp; The same code below would&amp;nbsp;result in the two passed in values being in different order in the two languages.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$core_v2_language.FormatString($core_v2_language.GetResource(&amp;quot;ValueWithFormatting&amp;quot;), $core_v2_group.Current.Name, $core_v2_application.Current.HtmlName(&amp;quot;web&amp;quot;))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1dfe5gvkd2"&gt;&lt;a id="Passing_a_resource_into_a_widget_s_JavaScript_files" name="Passing_a_resource_into_a_widget_s_JavaScript_files"&gt;&lt;/a&gt;From a JavaScript file&lt;/h3&gt;
&lt;p&gt;In some instances, it may be necessary to access a widget&amp;#39;s language resources while executing JavaScript.&amp;nbsp; In this instance, the resource values can be passed into the JavaScript register method and then referenced by the defined variable. It is important to JavaScript encode your resources in this instance, certain characters that could be present in resources will cause JavaScript errors.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="velocity"&gt;#registerEndOfPageHtml(&amp;#39;telligent.evolution.widgets.helloworld&amp;#39;)
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl(&amp;quot;ui.js&amp;quot;))&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
#end
#registerEndOfPageHtml()
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
		jQuery(function(){
			jQuery.telligent.evolution.widgets.helloworld.register({
				resourceText: &amp;#39;$core_v2_encoding.JavascriptEncode($core_v2_language.GetResource(&amp;quot;FromJavascript&amp;quot;))&amp;#39;
			});
		});
	&amp;lt;/script&amp;gt;
#end&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then in the JavaScript file, the resource can be retrieved using the name that was provided in the register method.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="javascript"&gt;(function($)
{
	if (typeof $.telligent === &amp;#39;undefined&amp;#39;) { $.telligent = {}; }
	if (typeof $.telligent.evolution === &amp;#39;undefined&amp;#39;) { $.telligent.evolution = {}; }
	if (typeof $.telligent.evolution.widgets === &amp;#39;undefined&amp;#39;) { $.telligent.evolution.widgets = {}; }

	$.telligent.evolution.widgets.helloworld =
	{
		register: function(context)
		{
            alert(context.resourceText);
		}
	};
})(jQuery);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>