1+ using Microsoft . Extensions . Localization ;
2+
13namespace Tevling . Components ;
24
35public partial class ActivityCard : ComponentBase
46{
57 [ Inject ] private IBrowserTime BrowserTime { get ; set ; } = null ! ;
8+ [ Inject ] private IStringLocalizer < ActivityCard > Loc { get ; set ; } = null ! ;
69
710 [ Parameter ] public Activity ? Activity { get ; set ; }
811
@@ -16,15 +19,15 @@ private string Stats
1619 if ( Activity . Details . DistanceInMeters > 0 )
1720 {
1821 float distanceInKm = Activity . Details . DistanceInMeters / 1000 ;
19- return $ "Distance: { distanceInKm : F1} km";
22+ return $ "{ Loc [ " Distance" ] } : { distanceInKm : F1} km";
2023 }
2124
2225 if ( Activity . Details . TotalElevationGain > 0 )
2326 {
24- return $ "Elevation: { Activity . Details . TotalElevationGain } m";
27+ return $ "{ Loc [ " Elevation" ] } : { Activity . Details . TotalElevationGain } m";
2528 }
2629
27- return Activity . Details . Calories > 0 ? $ "Calories: { Activity . Details . Calories } kcal" : string . Empty ;
30+ return Activity . Details . Calories > 0 ? $ "{ Loc [ " Calories" ] } : { Activity . Details . Calories } kcal" : string . Empty ;
2831 }
2932 }
3033
@@ -38,14 +41,14 @@ private string Time
3841 string formattedTime = "" ;
3942
4043 if ( timeSpan . Hours > 0 )
41- formattedTime += $ "{ timeSpan . Hours } h ";
44+ formattedTime += $ "{ timeSpan . Hours } { Loc [ "Hours" ] } ";
4245
4346 if ( timeSpan . Minutes > 0 || timeSpan . Hours > 0 ) // Include minutes if there are any hours
44- formattedTime += $ "{ timeSpan . Minutes } m ";
47+ formattedTime += $ "{ timeSpan . Minutes } { Loc [ "Minutes" ] } ";
4548
46- formattedTime += $ "{ timeSpan . Seconds } s ";
49+ formattedTime += $ "{ timeSpan . Seconds } { Loc [ "Seconds" ] } ";
4750
48- return $ "Time: { formattedTime } ";
51+ return $ "{ Loc [ " Time" ] } : { formattedTime } ";
4952 }
5053 }
5154
@@ -55,7 +58,7 @@ protected override async Task OnParametersSetAsync()
5558 if ( Activity != null )
5659 {
5760 DateTimeOffset browserTime = await BrowserTime . ConvertToLocal ( Activity . Details . StartDate ) ;
58- ActivityTime = browserTime . ToString ( "dd.MM.yyyy HH:mm " ) ;
61+ ActivityTime = browserTime . DateTime . ToString ( "G " ) ;
5962 }
6063 }
6164}
0 commit comments