How can I localize the excelent Piranha Headless CMS solution?
I want to be able to allow the user to select a language and display content in function of that selection. I just want to display two sets of pages, no globalization.

Kind regsrds,

Karel

Since the CMS itself isn’t multi-lingual at this point, your best option would be to add two different site, one for each language. In the hostnames field of your site your could for example set it up like:

mydomain.com      // For the default site
mydomain.com/lang // For the translated site

The downside of this would of course be having to manage two different sitemaps.

Another option would be to create a TranslationRegion where you can translate all of the base fields of the page, for example:

public class PageLocalization {
    [Field]
    public StringField Title { get; set; }
    [Field]
    public StringField NavigationTitle { get; set; }
    [Field]
    public StringField Keywords { get; set; }
    [Field]
    public TextField Description { get; set; }
}

You could also create a reusable region for HTML-content, like so:

public class HtmlLocalization {
    [Field]
    public HtmlField Body { get; set; }
    [Field]
    public HtmlField TranslatedBody { get; set; }
}

And then use these when building your page type.

[PageType(Title = "My Page")]
public class MyPage : Page<MyPage> {
    [Region]
    public PageLocalization PageLocalization { get; set; }
    [Region]
    public HtmlLocalization MainContent { get; set; }
}

With this solution you would only need one site and one sitemap, but views will have to handle which fields to use when rendering the site depending on the choosen language.

Like I mentioned earlier, there’s really no built in features in Piranha CMS for multi-lingual support, but it might be added in the future. There is a feature request for it at GitHub but it’s nothing that’s planned for development in the near future.

Regards

1