# Upgrade custom multilingual code

## Overview

Sitefinity CMS 13.1 has introduced changes to its Native API for working with multilingual content. The previous multilingual APIs are deprecated and no longer work, starting with Sitefinity CMS 13.1.

In this article, you learn how to migrate your existing code to the new APIs.

## APIs for working with current context language for Sitefinity CMS sites

You can use the following APIs starting with Sitefinity 13.1:

* To change the current language for a specific part of your code, use the `CultureRegion` class, as shown below.
* To get or set the current language for the current request, use the `SystemManager.CurrentContext.Culture` property.\
  The value set or returned is valid only for the current request.
* An exception is thrown if your code attempt to use a language that does not exist in the basic settings (to access them, navigate to *Administration » Settings » Languages*).

## **Sample**

The following code shows how to use the new `CultureRegion` code to set a specific culture/language for a part of your code.

**Create News Item**

```C#
using System.Globalization;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Workflow;

namespace SitefinityWebApp
{
    public static class MultilanguageAPIExamples
    {
        public static void CreateNewsItemFluentApi(string title, string content, CultureInfo culture)
        {
            using (new CultureRegion(culture))
            {
                App.WorkWith().NewsItem().CreateNew()
                    .Do(newsItem =>
                    {
                        newsItem.Title = title;
                        newsItem.Content = content;
                    })
                    .Publish()
                    .SaveChanges();
            }
        }

        public static void CreateNewsItemNativeApi(string newsTitle, string newsContent, CultureInfo culture)
        {
            using (new CultureRegion(culture))
            {
                NewsManager newsManager = NewsManager.GetManager();
                var newsItem = newsManager.CreateNewsItem();

                newsItem.Title = newsTitle;
                newsItem.Content = newsContent;

                newsManager.RecompileAndValidateUrls(newsItem);

                newsItem.ApprovalWorkflowState = ApprovalStatusConstants.Published;
                newsManager.Lifecycle.Publish(newsItem);

                newsManager.SaveChanges();
            }
        }

    }
}
```

## All languages and default language APIs: Sitefinity 13.0 and below

> important **IMPORTANT**: The following are breaking changes starting with Sitefinity 13.1:

* Setting the `CultureInfo.CurrentCulture`, `CultureInfo.CurrentUICulture`, `Thread.CurrentUICulture`, or `Thread.CurrentCulture` no longer changes the current Sitefinity language.\
  For example, the following code does not work:\
  `Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");`

The following APIs are deprecated, starting with Sitefinity 13.1. If you used them in your solution based on Sitefinity CMS version older than 13.1, substitute their usage with the new APIs described below:

### Get all languages

To get all languages and default language for the current site, use one of the following:

* `SystemManager.CurrentContext.AppSettings`with the following properties
  * `DefinedFrontendLanguages`
  * `DefaultFrontendLanguage`
  * `Multilingual`
* `SystemManager.CurrentContext.CurrentSite`with the following properties:
  * `PublicContentCultures`
  * `DefaultCulture`

### Retrieve language information

To retrieve information for languages in Administration » Settings » Languages, use `AppSettings.CurrentSettings` with the following properties:

* `DefinedFrontendLanguages`
* `DefaultFrontendLanguage `
* `Multilingual`

## All languages and default language API: Sitefinity 13.1 and above

The following APIs are available starting with Sitefinity CMS 13.1 and above and are the new alternatives to the above-described deprecated API. When upgrading to Sitefinity CMS version 13.1 and above, you need to rewrite your code to use the new API.

The `SystemManager` class is the single API entry point for getting information for the cultures and languages in Sitefinity CMS.

### Get all languages

To get all languages and default language for the current site, use `SystemManager.CurrentContext.CurrentSite` with the following methods:

* `Cultures`\
  Lists all cultures and languages for the current Sitefinity site
* `DefaultCulture`\
  Lists the default cultures and language for the current Sitefinity site

### Retrieve language information

To retrieve information for languages in *Administration* » *Settings* » *Languages*, use `SystemManager.CurrentContext` with the following methods:

* `SystemCultures`\
  Lists all available languages and cultures available in the whole system
* `DefaultSystemCulture`

### Check for multiple languages

To see if the current site has more than one language, use the following code: `SystemManager.CurrentContext.CurrentSite.Cultures.Count() > 1`
