Skip to main content
Home  › ... Razor

Multi-Language Tutorial

Tutorial HomeLanguages
Error Showing Content - please login as admin for details.
The samples can differ based on your Razor base class or if you're running an old version.
Switch to Typed (2sxc 16+) Selected: Dynamic (Razor14 or below)

Multi-Language (i18n) Resources

These are configured in the App Resources or in the global resources.

⬇️ Result | Source ➡️

  1. The Greeting Text:

    Welcome to the Tutorial App!

    This is the English greeting 😉!

  2. A button:
@inherits Custom.Hybrid.Razor14
<ol>
  <li>The Greeting Text: <br>
    @Html.Raw(App.Resources.Get("Greeting"))
  </li>
  <li>
    A button:
    <button type="button">@App.Resources.Get("ButtonOrder")</button>
  </li>
</ol>

Multi-Language (i18n) Content

The editor can edit anything and choose which field to translate. In the following example, only one book is translated - and even the cover-image is translated.

⬇️ Result | Source ➡️

  • Hitchhikers Guide to the Galaxy
    Seconds before the Earth is demolished to make way for a galactic freeway, Arthur Dent is plucked…
  • Good Omens
    The Nice and Accurate Prophecies of Agnes Nutter, Witch is a World Fantasy Award-nominated novel…
  • Phishing for Phools
    Markets are full of manipulative traps, and we can all be easily coerced into spending money to our…
  • The Last Continent
    Ane awesome parody of Australians.
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade
@{
  // Resize settings for the cover images
  var flatSettings = Kit.Image.Settings(width: 100, height: 300, resizeMode: "max", scaleMode: "both");
}
<ul>
  @foreach (var book in AsList(App.Data["Books"])) {
    <li class="mb-4">
      <div style="overflow: auto">
        @if (Text.Has(book.Cover)) {
          @Kit.Image.Img(book.Cover, settings: flatSettings, imgClass: "float-start pe-4")
        }
        <strong>@book.Title</strong> <br>
        @Text.Ellipsis(book.Teaser, 100, suffix: "…")
      </div>
    </li>
  }
</ul>