<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>compiler &#8211; MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/compiler/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Tue, 07 Apr 2020 13:43:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>compiler &#8211; MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>Multilingual applications with VB.NET</title>
		<link>https://www.maxvergelli.com/developing-multilingual-applications-with-vb-net-c-sharp/</link>
					<comments>https://www.maxvergelli.com/developing-multilingual-applications-with-vb-net-c-sharp/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 09 Aug 2019 14:36:19 +0000</pubDate>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[culture-codename]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[intellisense]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[multi-language]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[resx]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[String-class]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[visual-studio]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=49</guid>

					<description><![CDATA[In this simple tutorial you&#8217;ll learn how to manage different languages for a vb.NET application and the simplest way to access programmatically to the string values in the resource compiled files (*.resx) created by Visual Studio; Adding resource files: First &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/developing-multilingual-applications-with-vb-net-c-sharp/" aria-label="Multilingual applications with VB.NET">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>In this simple tutorial you&#8217;ll learn how to manage different languages for a vb.NET application and the simplest way to access programmatically to the string values in the resource compiled files (*.resx) created by Visual Studio;</p>
<p><strong>Adding resource files:</strong></p>
<p>First of all, add a folder named &#8220;resources/&#8221; in your project.</p>
<p>Inside this folder, right click then from the context menu choose &#8220;add an element&#8221; -> &#8220;new element&#8221; -> select &#8220;Resource File (resx)&#8221; -> create a file named &#8220;Resources.en-US.resx&#8221;</p>
<p>In the &#8220;Resources.en-US.resx&#8221; file, You have to write all the strings used by your application.<br />
It&#8217;s important that your language resource file is named as &#8220;Resources.{Language Code Name}.resx&#8221;, so VS can reach automatically this file.</p>
<p>The rsx file is just a list of Key-Value items, then You have to give a key-name for each string value; don&#8217;t use spaces in key-names, otherwise it&#8217;s best using &#8220;_&#8221; symbol.</p>
<p>Insert only two test lines in your new rsx file as the following&#8230;</p>
<p>KEY &#8211; VALUE:<br />
<code><br />
TEST_STRING1	us1<br />
TEST_STRING2	us2<br />
</code></p>
<p>Then, compile your project and if it&#8217;s all right, You will find a new folder in &#8220;binRelease&#8221; named &#8220;en-US&#8221; created by VS, with a file &#8220;{your project name}.resources.dll&#8221;; this file contains all the strings for the english-US language (&#8220;en-US&#8221;) and right now You can access them programmatically.</p>
<p>If You want add a new language to your application, just copy the rsx file and rename it in &#8220;Resources.{Language Code Name}.resx&#8221; where the language code name is one of those listed at <a href="http://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx" title="http://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx" target="_blank" rel="noopener noreferrer">http://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx</a>.</p>
<p><strong>Step 2, how to programmatically select the language and strings:</strong></p>
<p>Add a vb class &#8220;Resources.vb&#8221; in the &#8220;resources&#8221; folder with the following code</p>
[sourcecode language=&#8221;vb&#8221;]
Public Class Resources</p>
<p>    Public Shared Function GetValue(ByVal name As ResourceName) As String<br />
        Return My.Resources.ResourceManager.GetObject(name.ToString)<br />
    End Function</p>
<p>    Public Shared Property Language() As CultureCodeName<br />
        Get<br />
            Dim c As CultureCodeName = Nothing<br />
            Dim cs As String = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString().Replace(New Char() {&quot;-&quot;c}, New Char() {&quot;_&quot;c})<br />
            For Each cc As CultureCodeName In [Enum].GetValues(GetType(CultureCodeName))<br />
                If cs = cc.ToString Then<br />
                    c = cc<br />
                    Exit For<br />
                End If<br />
            Next<br />
            Return c<br />
        End Get<br />
        Set(ByVal cultureCodeName As CultureCodeName)<br />
            Dim c As String = cultureCodeName.ToString.Replace(New Char() {&quot;_&quot;c}, New Char() {&quot;-&quot;c})<br />
            System.Threading.Thread.CurrentThread.CurrentUICulture = _<br />
                            System.Globalization.CultureInfo.GetCultureInfo(c)<br />
        End Set<br />
    End Property</p>
<p>End Class<br />
[/sourcecode]
<p>then, add a vb &#8220;code file&#8221; named &#8220;CultureCodeNames.vb&#8221; in &#8220;resources&#8221; folder with the following code</p>
[sourcecode language=&#8221;vb&#8221;]
<p>Public Enum CultureCodeName</p>
<p>    en_US<br />
    &#8216;if You want add a new language, after creating the rsx file,<br />
    &#8216;also add here the code name, with &quot;-&quot; replaced in &quot;_&quot;</p>
<p>End Enum</p>
[/sourcecode]
<p>Finally, add the last vb codefile &#8220;ResourceNames.vb&#8221; in &#8220;resources&#8221; folder with this code</p>
[sourcecode language=&#8221;vb&#8221;]
<p>Public Enum ResourceName</p>
<p>    &#8216;add here all the key names in the RSX file<br />
    TEST_STRING1<br />
    TEST_STRING2</p>
<p>End Enum</p>
[/sourcecode]
<p>The configuration is finished.<br />
In your project, add a button to a form, then add the following vb code in the <em>codebehind</em> to learn how to access to different language RSX files and their strings inside.</p>
[sourcecode language=&#8221;vb&#8221;]
<p>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click</p>
<p>        &#8216;Select a language for your app<br />
        Resources.Language = CultureCodeName.en_US</p>
<p>        &#8216;show test string 1<br />
        MessageBox.Show(Resources.GetValue(ResourceName.TEST_STRING1))</p>
<p>        &#8216;show test string 2<br />
        MessageBox.Show(Resources.GetValue(ResourceName.TEST_STRING2))</p>
<p>        &#8216;show the current language code<br />
        MessageBox.Show(Resources.Language.ToString)</p>
<p>    End Sub<br />
[/sourcecode]
<p>It&#8217;s very useful because when you will be writing the code, VS automatically suggests the strings that you can use, saving a lot of time and by selecting a language with &#8220;Resources.Language&#8221;, You can translate your application strings on the fly. </p>
<p>Have a nice day!</p>
<p>Max</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/developing-multilingual-applications-with-vb-net-c-sharp/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">49</post-id>	</item>
	</channel>
</rss>
