Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Deal with multiple cultures

Gustavo Denis edited this page Oct 31, 2019 · 1 revision
Main > Using Liquid for building your application > Deal with multiple cultures
##Set application culture

Internationalization involves Globalization and Localization. Globalization is the process of designing apps that support different cultures. Localization is the process of adapting a globalized app, which you have already processed for localizability, to a particular culture/locale. Liquid is Multilanguage and is capable to translate to any culture

##Business Critics Liquid has three types of Critic Handler that can be presented on the interface in any culture.

BusinessInformation: String with an information to the user. BusinessWarning: String with a warning to the user. BusinessError: String with a error message to the user.

ServiceBasket.cs

public DomainResponse DeleteBasket(string basketId)
        {
            if (string.IsNullOrEmpty(basketId))
            {
                AddBusinessError("BASKET_ID_MUST_NOT_BE_EMPTY"); 
            }
            if (basketId.Length < 3)
            {
                AddBusinessWarning("BASKET_ID_LENGHT_LESS_THAN_THREE");
            }
            if (basketId.Length < 5)
            {
                AddBusinessInfo("BASKET_ID_LENGHT_LESS_THAN_FIVE");
            }

            Repository.DeleteAsync(basketId);
            //Some final business logic 
            return Response(basketId);
        }

##Resources

Create a folder "Resources" containing the .json file with the translations.

image.png

localization.json

{
BASKET_ID_MUST_NOT_BE_EMPTY: " The basketId must not be empty",
BASKET_ID_LENGHT_LESS_THAN_THREE: "The basketId must be more than 3 letters",
BASKET_ID_LENGHT_LESS_THAN_FIVE:"The basketId must be more than 5 letters"
}

localizationpt-BR.json

{
BASKET_ID_MUST_NOT_BE_EMPTY: "O campo basketId não pode estar vazio",
BASKET_ID_LENGHT_LESS_THAN_THREE: "O campo basketId deve conter mais do que 3 caracteres",
BASKET_ID_LENGHT_LESS_THAN_FIVE:"O campo basketId deve conter mais do que 5 caracteres"
}

##appsettings.json

Define the default culture on appsettings.json. Case it'ss not defined, "en-US" will be the default culture.

  "Localization": {
    "DefaultCulture": "en-US",
    "SupportedCultures": ["en-US","pt-BR", "es-ES"]
  },

The system will reflect the selected culture.

Clone this wiki locally