M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

ILanguage and IPhrase

In today’s diverse ecommerce world it is very important for a web application to offer functionality to multiple cultures, which is called globalization. In this tutorial, we will focus on two interfaces, which enables an application to support one aspect of globalization i.e. language. M# framework contains definitions of two interfaces "ILanguage" and "IPhrase", which can be implemented to enable multi-lingual websites.

ILanguage Interface

This interface is defined under "MSharp.Framework.Services.Globalization". There are three properties defined in this interface, as shown below:

This interface implementation allows management of different languages with the name and ISO code. "IsDefault" property should determine the default language.

IPhraseTranslation Interface

A phrase in normal English is defined as "A small group of words standing together as a conceptual unit". The purpose of this interface is to maintain the default phrase and it’s translation with the translation language reference together. This interface is also defined under "MSharp.Framework.Services.Globalization" and also contains three properties definition.

Important: Both interfaces explained above must be implemented in model in order to perform translation of UI contents using M# framework. All phrase on the UI should be stored in a database table based on the entity that implements this interface. The saved phrases are then translated based on the interface implementation. In the next tutorial we explain how to configure an application to support multi-lingual functionality and how you should develop UI to fully benefit from M# globalization namespace.

Translator Class

Translator static class is available under "MSharp.Framework.Services.Globalization" namespace and encapsulates translation related functionality by utilizing the aforementioned interface implementation or by using Google translation. This class exposes very useful methods, which are used to perform translation of phrases. The method definitions shown below are used to translate phrases based on the implementation of interfaces discussed above.

M# uses the default language to translate UI contents, which is explained in the next tutorial. This class also provides two events, which are used to perform custom actions required at the time when translation is requested and when the translation is downloaded using internet services, the screenshot below shows the events:

Translator static class also contains the implementation of Google translation with auto language detection. You can call methods shown above to use Google translation service but remember that you must configure Google translation API Key in web.config (Explained in next tutorial).

M# translation model also supports HTML translation, which can be performed by using the methods shown below.