I have the following code that is switching languages nicely. However it's showing ALL languages installed rather than just the languages in use. I noticed Vorto manages to get a list of "in use" languages. Is it possible at the front end and how would you do it?
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Globalization;
@using Umbraco.Core;
@{
var thisPage = Model.Content.Url;
var currentLang = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
var localService = ApplicationContext.Current.Services.LocalizationService;
<div class="col-xxs-6 col-s-3 col-m-2 lang-switch push">
@foreach (var lang in localService.GetAllLanguages()) {
var thisLang = lang.CultureInfo.TwoLetterISOLanguageName;
var currentPage = Model.Content.UrlName;
var url = Model.Content.DocumentTypeAlias == "homePage"
? "/" + thisLang
: "/" + thisLang + currentPage;
var activeClass = currentLang == thisLang ? " active" : "";
<div class="lang pull@(activeClass)"><a href="@url">@thisLang.ToUpper()</a></div>
}
</div>
}
7 minitues in to the episode, Matt takes about how to configure the Vorto so you only get the list of the languages that is used by the website, and the languages needs to be assigned as a hostname in your Umbraco installation.
Yes that's about the back end, my question is about the front end. I'm building a language switcher partial. I want to be able to just list the languages that are used, like Vorto can in it's dateType, but on the front end, and without using anything nasty that would slow the front end down like the contentservice :) I guess it's more of a Vorto question than an Umbraco question really.
That article is for a one site per language implementation, not a Vorto one site for all languages implementation.
My language switcher works fine (see code above). It's just that it's showing all languages that have been added to the Settings/Languages section whereas what I want is to show all languages added to the site's Culture and Hostnames settings, that's all. I could remove languages from the settings to achieve the same display on the language switcher but I wondered if there was a better way.
Vorto - list all languages in use
Umb 7.4.1 & Vorto 1.5.0
I have the following code that is switching languages nicely. However it's showing ALL languages installed rather than just the languages in use. I noticed Vorto manages to get a list of "in use" languages. Is it possible at the front end and how would you do it?
Thanks,
Craig
Hi Craig,
Have you seen the uHangout episode on how Vorto works, if not try to see this episode here http://uhangout.co.uk/videos/ep029-with-matt-brailsford-multi-language-translation-with-vorto/
7 minitues in to the episode, Matt takes about how to configure the Vorto so you only get the list of the languages that is used by the website, and the languages needs to be assigned as a hostname in your Umbraco installation.
Hope this helps,
/Dennis
Hi Dennis,
Yes that's about the back end, my question is about the front end. I'm building a language switcher partial. I want to be able to just list the languages that are used, like Vorto can in it's dateType, but on the front end, and without using anything nasty that would slow the front end down like the contentservice :) I guess it's more of a Vorto question than an Umbraco question really.
Or.... Putting it another way.......
How can you list the languages and/or cultures set on the site in the Culture and Hostnames settings?
:)
Hi Craig,
DonĀ“t know if this article from the Umbraco advent calendar from 2014 http://24days.in/umbraco/2014/razor-language-switcher/ can help you to build a language switcher
Hope this helps, or inspires you to a solution.
/Dennis
Hi Dennis,
That article is for a one site per language implementation, not a Vorto one site for all languages implementation.
My language switcher works fine (see code above). It's just that it's showing all languages that have been added to the Settings/Languages section whereas what I want is to show all languages added to the site's Culture and Hostnames settings, that's all. I could remove languages from the settings to achieve the same display on the language switcher but I wondered if there was a better way.
I've the same problem.
The solution I found is to check one property that I'm sure is filled if a page has been translated and see which languages it has.
is working on a reply...