Friday, June 24, 2011

Customizing strings


With SFS Tools, all fields support localization, so the way to change is through resource files, or any other localization provider.

The automatic generation of the solution creates all the necessary resource files for each business object and other necessary for the module. All resource files in a folder and are easy to modify.


Build a sample application.


Changing text for each language.

  1. In the presentation project (ASP.NET MVC) of business module, open the "Resources" folder and see that each business entity there is a resource file.
  2. Select the file to customize the business object, in this case: "ProductResources.resx", right click and select "Copy" from the context menu and "Ctrl + v" paste in the same folder (which will create a file name: "Copy of ProductResources.resx").
    image   image
  3. Select the file "Copy of ProductResources.resx" and right click to select "Rename" from the context menu and rename it adding ".es-mx" (Or any other localization id) before the ". resx" . Now the name file is " "
  4. Open the file "" with double click and change the following texts:
    PRODUCTS_ADD_NEW”, “PRODUCTS_DETAILS”, “PRODUCTS_EDIT” and  “PRODUCTS_LIST”  used for the title of the forms in CRUD operations (create, read, update and delete).
    The fields ENTITY_PLURAL and ENTITY_SINGLE, are important because they are used for build the site map menu.
    You can change any other file, for this example change only 3: "NAME", "PRODUCTMODEL"  Relationship to one (Foreign Key) and "PRODUCTSTHISTORIES" (Relationship to many).
  5. Right click on the application "SFS.AdventureWorks.Web.Mvc" and select "Build" from the context menu.
    The application is compiling and generating the assemblies to be deposited in the bin folder of the web project shell (SFSdotNet.Framework.Web.Mvc).
  6. Run the application.
  7. Go to “lista de productos” (Sorry by language for this sample)
    image  image  image
    See how the grid column header "Name" has been changed to "Nombre" and the title of the form has changed to.
  8. Right click on the row with the Name: “” and select "Details" from the context menu.
    This will open the form details of the "Product", and you can see how the strings of the properties have changed.
    image  image 
    The effects of the localization are more that this, it is important to note that even with that all functionality related with "business entity" is localized and integrated automatically.
    For example, if you return to the "Product List" and click on the link "Abrir búsqueda avanzada", then "Agregar filtro" then you can see that also in the filter engine has the effect of localization.
    image  image

Now, how does this? Es implementando los atributos de localización en el modelo. It is implementing the localization attributes in the model.


A good practice recommended by Microsoft but that can cost many hours if not using an automation tool.

Setting the language of the application.

In this example we have localized in Spanish - Mexico (es-mx), but you can do to the language you require and you should consider two options: a  specific localization language or can be configured automatically in the Shell project's web.config file from SFSdotNet.Framework.Web.Mvc project

  • Using a specific language
    <globalization culture="es-mx" uiCulture="es-mx" requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" fileEncoding="ISO-8859-1"/>
  • Using a automatic language
    <globalization culture="Auto" uiCulture="Auto" requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" fileEncoding="ISO-8859-1"/>


All text in a solution with SFS Tools are fully localized via  resource files in one place: the "Resources" folder.  Its complexity is reduced to copy, paste and translate.

No comments:

Post a Comment