private void PreviousElementHandler() { SelectedItem = SelectedItem == null || SelectedItem == Translations.First() ? Translations.Last() : Translations.Where(t => t.Id == SelectedItem.Id - 1).First(); EncodingVM.SetItem(SelectedItem); }
public string?Translate(string?culture = null) { if (Translations == null) { return(null); } culture = culture?.Trim() ?? Thread.CurrentThread.CurrentUICulture.Name; /* * in database - en, en-GB * in query - en, en-GB, en-US */ // do we have exact match - en-GB == en-GB var translation = Translations.FirstOrDefault(t => t.Culture == culture); if (translation != null) { return(translation.Value); } // do we have match without the region en-US.StartsWith(en) translation = Translations.FirstOrDefault(t => culture.StartsWith(t.Culture)); if (translation != null) { return(translation.Value); } // try to find the default culture translation = Translations.FirstOrDefault(t => culture.StartsWith(_defaultCulture)); if (translation != null) { return(translation.Value); } // just return the first in list or null return(Translations?.First().Value); }