diff --git a/AMC.View/App.xaml.cs b/AMC.View/App.xaml.cs index 4598800..d855210 100644 --- a/AMC.View/App.xaml.cs +++ b/AMC.View/App.xaml.cs @@ -1,4 +1,6 @@ -namespace AMC.View; +using System.Globalization; + +namespace AMC.View; public partial class App : Application { @@ -8,4 +10,14 @@ public partial class App : Application MainPage = new AppShell(); } + + protected override void OnStart() + { + base.OnStart(); + // Uncomment to set the culture to French + + // CultureInfo.CurrentCulture = new CultureInfo("fr-FR"); + // CultureInfo.CurrentUICulture = new CultureInfo("fr-FR"); + + } } diff --git a/AMC.View/Converters/AlbumDetailsConverter.cs b/AMC.View/Converters/AlbumDetailsConverter.cs new file mode 100644 index 0000000..5e80d87 --- /dev/null +++ b/AMC.View/Converters/AlbumDetailsConverter.cs @@ -0,0 +1,22 @@ +using System.Globalization; + +namespace AMC.View.Converters +{ + public class AlbumDetailsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var (genre, year) = (ValueTuple)value; + return string.Format( + "{0} · {1}", + genre, + year + ); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AMC.View/Converters/CopyrightInfoConverter.cs b/AMC.View/Converters/CopyrightInfoConverter.cs new file mode 100644 index 0000000..bd7c993 --- /dev/null +++ b/AMC.View/Converters/CopyrightInfoConverter.cs @@ -0,0 +1,22 @@ +using System.Globalization; + +namespace AMC.View.Converters +{ + public class CopyrightInfoConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var (copyrightYear, producerBlurb) = (ValueTuple)value; + return string.Format( + "℗ {0} {1}", + copyrightYear, + producerBlurb + ); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AMC.View/Converters/SongsInfoConverter.cs b/AMC.View/Converters/SongsInfoConverter.cs new file mode 100644 index 0000000..6a63476 --- /dev/null +++ b/AMC.View/Converters/SongsInfoConverter.cs @@ -0,0 +1,27 @@ +using AMC.View.Resources.Strings; +using System.Globalization; + +namespace AMC.View.Converters +{ + public class SongsInfoConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var (songCount, totalDuration) = (ValueTuple)value; + var songLabel = songCount == 1 ? Strings.SongsLabelSingular : Strings.SongsLabelPlural; + var minutesLabel = totalDuration == 1 ? Strings.MinutesLabelSingular : Strings.MinutesLabelPlural; + return string.Format( + "{0} {1}, {2} {3}", + songCount, + songLabel, + totalDuration, + minutesLabel + ); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AMC.View/Resources/Strings/Strings.Designer.cs b/AMC.View/Resources/Strings/Strings.Designer.cs index 9961783..e0343fe 100644 --- a/AMC.View/Resources/Strings/Strings.Designer.cs +++ b/AMC.View/Resources/Strings/Strings.Designer.cs @@ -60,6 +60,33 @@ namespace AMC.View.Resources.Strings { } } + /// + /// Looks up a localized string similar to Library. + /// + public static string LibraryTitle { + get { + return ResourceManager.GetString("LibraryTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minutes. + /// + public static string MinutesLabelPlural { + get { + return ResourceManager.GetString("MinutesLabelPlural", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to minute. + /// + public static string MinutesLabelSingular { + get { + return ResourceManager.GetString("MinutesLabelSingular", resourceCulture); + } + } + /// /// Looks up a localized string similar to Play. /// @@ -77,5 +104,23 @@ namespace AMC.View.Resources.Strings { return ResourceManager.GetString("ShuffleButton", resourceCulture); } } + + /// + /// Looks up a localized string similar to songs. + /// + public static string SongsLabelPlural { + get { + return ResourceManager.GetString("SongsLabelPlural", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to song. + /// + public static string SongsLabelSingular { + get { + return ResourceManager.GetString("SongsLabelSingular", resourceCulture); + } + } } } diff --git a/AMC.View/Resources/Strings/Strings.fr.resx b/AMC.View/Resources/Strings/Strings.fr.resx index 5f443b9..22819ed 100644 --- a/AMC.View/Resources/Strings/Strings.fr.resx +++ b/AMC.View/Resources/Strings/Strings.fr.resx @@ -123,4 +123,19 @@ Aléatoire + + Bibliothèque + + + morceaux + + + minutes + + + morceau + + + minute + \ No newline at end of file diff --git a/AMC.View/Resources/Strings/Strings.resx b/AMC.View/Resources/Strings/Strings.resx index 477b48f..7400d27 100644 --- a/AMC.View/Resources/Strings/Strings.resx +++ b/AMC.View/Resources/Strings/Strings.resx @@ -123,4 +123,19 @@ Shuffle + + Library + + + songs + + + minutes + + + song + + + minute + \ No newline at end of file diff --git a/AMC.View/Views/AlbumPage.xaml b/AMC.View/Views/AlbumPage.xaml index 00ea42b..5495e4f 100644 --- a/AMC.View/Views/AlbumPage.xaml +++ b/AMC.View/Views/AlbumPage.xaml @@ -3,9 +3,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:AMC.View" xmlns:strings="clr-namespace:AMC.View.Resources.Strings" + xmlns:conv="clr-namespace:AMC.View.Converters" xmlns:vm="clr-namespace:AMC.ViewModel.ViewModels;assembly=AMC.ViewModel" x:Class="AMC.View.Views.AlbumPage" x:DataType="vm:AlbumViewModel"> + + + + + + + + @@ -41,7 +50,7 @@ - diff --git a/AMC.ViewModel/ViewModels/AlbumViewModel.cs b/AMC.ViewModel/ViewModels/AlbumViewModel.cs index 38ee65c..61a80b4 100644 --- a/AMC.ViewModel/ViewModels/AlbumViewModel.cs +++ b/AMC.ViewModel/ViewModels/AlbumViewModel.cs @@ -18,13 +18,15 @@ namespace AMC.ViewModel.ViewModels public string CoverImage => album.CoverImage; - public string Details => $"{album.Genre} · {album.Year}"; + public (string Genre, int Year) Details => (album.Genre, album.Year); - public string ReleaseDate => album.ReleaseDate.ToString("d MMMM yyyy"); + public DateTime ReleaseDate => album.ReleaseDate; - public string SongsInfo => $"{album.Songs.Count} songs, {album.Songs.Sum(song => song.Duration) / 60} minutes"; + public (int SongCount, int TotalDuration) SongsInfo + => (album.Songs.Count, album.Songs.Sum(song => song.Duration) / 60); - public string CopyrightInfo => $"℗ {album.CopyrightYear} {album.ProducerBlurb}"; + public (int CopyrightYear, string ProducerBlurb) CopyrightInfo + => (album.CopyrightYear, album.ProducerBlurb); public ReadOnlyObservableCollection Songs => new(songs);