Set the following values:
Resource File Type: resx
Resource File Frequency: Project
Retrieval Method: <%=GetString("[key]")%>
String Key Next ID: 1
Share Strings: Checked
Externalized String Comment: GLOBALYZER_EXTERNALIZED_TEXT:
Resource File Path: [Simple Project Path]/MyResources.resx (Note: You can browse to the directory for easier setting.)
Resource File Encoding: UTF-8
Check to ensure that
the settings now look like this:
Let's look at what these settings mean.
First, note that the term externalize refers to replacing
embedded text in source files with a method call to retrieve the
text from a resource file. Globalyzer's String Externalization
feature automatically extracts embedded display text, such as
button names or error messages, from the source and places the
text in a resource file with a unique key that identifies it.
The Resource File Type is set to resx. This tells
Globalyzer to place externalized strings in a .NET resx-style XML
file.
The Resource File Frequency is set to Project. This
means that only one resource file will be created for this
Globalyzer project. The other option, Source File,
specifies that a unique resource file will be created for each
source file from which strings are externalized. Because you are
going to create the default .resx file that will be built into
the main .NET Web assembly, you can create a single file that
will store strings for all of the source files in this project.
The Retrieval Method specifies a fully qualified method
name that will be used to retrieve text from the compiled
resource dll at runtime. The actual name of this method is
generally specific to each system architecture. In our code, you
are going to make sure each class has a member method called
GetString. In other words, all of the code you alter will need to
have access to a method called GetString that can retrieve the
externalized text.
In the .NET source files, you will alter every code-behind
class generated by Visual Studio.NET for each .aspx file to
extend a class called StringGetter.cs. That class defines a
GetString method that in turn calls the GetString method in
ResourceManager. ResourceManager is the .NET class responsible
for - as the name suggests - managing Resources. Bear in mind
that in a real-world application that is pulling in translated
text, the UICulture would need to be set dynamically for each
user to ensure that the correctly-translated resources are
displayed in the GUI.
As noted previously, each string that is externalized is assigned
a unique identifying key. To ensure uniqueness, the current String
Key Next ID is prepended to the identifying key and then
incremented.
Notice also that we include the server-side tags with the method
signature. This is because any HTML strings we externalize will
be replaced with this entire Retrieval Method text,
including the server-side tags.
By setting Share Strings to Yes, you tell
Globalyzer to reuse the same key/value pair for identical
embedded strings. In other words, only one key/value would be
generated for each Cancel string in the application.
The Resource File Path is set to create the file MyResources.resx
in the directory where you put the source code (assuming the
default path was left unchanged). Again, because the Resource
File Frequency is set to Project, this resource file will
be used to store the key/value pairs for the entire project.
Note: If you leave the Resource File Path with just
a directory name, and your Resource File Frequency is set
to Project, Globalyzer will create a .resx file
using the name of the Project. For example, for the Simple
Project, Globalyzer will create the resource file Simple.resx.
Finally, the Resource File Encoding should be set to UTF-8, as this is
the preferred encoding of resx files. Globalyzer will assume all your resource files
of this type are the same encoding, although it will ensure that if a resource file has
BOM bytes (bytes at the beginning of the file that indicate encoding), it will access the
file properly, regardless the Project's Resource File Encoding setting. To see the
encoding of an individual file, right-click on the file in the Project Explorer view
and select Properties.