Skip to content

Commit

Permalink
feat(locale): player, playlist view, track tile bengali and english t…
Browse files Browse the repository at this point in the history
…ranslations
  • Loading branch information
Kingkor Roy Tirtho committed Apr 29, 2023
1 parent 11fe9ec commit c55133d
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 59 deletions.
7 changes: 4 additions & 3 deletions lib/components/player/player_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/player/player_queue.dart';
import 'package:spotube/components/player/sibling_tracks_sheet.dart';
import 'package:spotube/components/shared/heart_button.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/models/local_track.dart';
import 'package:spotube/models/logger.dart';
import 'package:spotube/provider/authentication_provider.dart';
Expand Down Expand Up @@ -55,7 +56,7 @@ class PlayerActions extends HookConsumerWidget {
children: [
IconButton(
icon: const Icon(SpotubeIcons.queue),
tooltip: 'Queue',
tooltip: context.l10n.queue,
onPressed: playlist != null
? () {
showModalBottomSheet(
Expand All @@ -81,7 +82,7 @@ class PlayerActions extends HookConsumerWidget {
if (!isLocalTrack)
IconButton(
icon: const Icon(SpotubeIcons.alternativeRoute),
tooltip: "Alternative Track Sources",
tooltip: context.l10n.alternative_track_sources,
onPressed: playlist?.activeTrack != null
? () {
showModalBottomSheet(
Expand Down Expand Up @@ -115,7 +116,7 @@ class PlayerActions extends HookConsumerWidget {
)
else
IconButton(
tooltip: 'Download track',
tooltip: context.l10n.download_track,
icon: Icon(
isDownloaded ? SpotubeIcons.done : SpotubeIcons.download,
),
Expand Down
19 changes: 11 additions & 8 deletions lib/components/player/player_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:palette_generator/palette_generator.dart';

import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/collections/intents.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/use_progress.dart';
import 'package:spotube/models/logger.dart';
import 'package:spotube/provider/playlist_queue_provider.dart';
Expand Down Expand Up @@ -133,7 +134,7 @@ class PlayerControls extends HookConsumerWidget {
return Column(
children: [
Tooltip(
message: "Slide to seek forward or backward",
message: context.l10n.slide_to_seek,
child: Slider(
// cannot divide by zero
// there's an edge case for value being bigger
Expand Down Expand Up @@ -181,8 +182,8 @@ class PlayerControls extends HookConsumerWidget {
children: [
IconButton(
tooltip: playlist?.isShuffled == true
? "Unshuffle playlist"
: "Shuffle playlist",
? context.l10n.unshuffle_playlist
: context.l10n.shuffle_playlist,
icon: const Icon(SpotubeIcons.shuffle),
style: playlist?.isShuffled == true
? activeButtonStyle
Expand All @@ -198,13 +199,15 @@ class PlayerControls extends HookConsumerWidget {
},
),
IconButton(
tooltip: "Previous track",
tooltip: context.l10n.previous_track,
icon: const Icon(SpotubeIcons.skipBack),
style: buttonStyle,
onPressed: playlistNotifier.previous,
),
IconButton(
tooltip: playing ? "Pause playback" : "Resume playback",
tooltip: playing
? context.l10n.pause_playback
: context.l10n.resume_playback,
icon: playlist?.isLoading == true
? SizedBox(
height: 20,
Expand All @@ -224,15 +227,15 @@ class PlayerControls extends HookConsumerWidget {
),
),
IconButton(
tooltip: "Next track",
tooltip: context.l10n.next_track,
icon: const Icon(SpotubeIcons.skipForward),
style: buttonStyle,
onPressed: playlistNotifier.next,
),
IconButton(
tooltip: playlist?.isLooping != true
? "Loop Track"
: "Repeat playlist",
? context.l10n.loop_track
: context.l10n.repeat_playlist,
icon: Icon(
playlist?.isLooping == true
? SpotubeIcons.repeatOne
Expand Down
3 changes: 2 additions & 1 deletion lib/components/root/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:spotube/components/player/player_actions.dart';
import 'package:spotube/components/player/player_overlay.dart';
import 'package:spotube/components/player/player_track_details.dart';
import 'package:spotube/components/player/player_controls.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/use_breakpoints.dart';
import 'package:spotube/hooks/use_brightness_value.dart';
import 'package:spotube/models/logger.dart';
Expand Down Expand Up @@ -130,7 +131,7 @@ class BottomPlayer extends HookConsumerWidget {
PlayerActions(
extraActions: [
IconButton(
tooltip: 'Mini Player',
tooltip: context.l10n.mini_player,
icon: const Icon(SpotubeIcons.miniPlayer),
onPressed: () async {
await DesktopTools.window.setMinimumSize(
Expand Down
13 changes: 9 additions & 4 deletions lib/components/shared/heart_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import 'package:spotify/spotify.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/use_palette_color.dart';
import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/services/mutations/mutations.dart';
Expand Down Expand Up @@ -120,7 +121,9 @@ class TrackHeartButton extends HookConsumerWidget {
}

return HeartButton(
tooltip: toggler.item1 ? "Remove from Favorite" : "Add to Favorite",
tooltip: toggler.item1
? context.l10n.remove_from_favorites
: context.l10n.save_as_favorite,
isLiked: toggler.item1,
onPressed: savedTracks.hasData
? () {
Expand Down Expand Up @@ -174,8 +177,8 @@ class PlaylistHeartButton extends HookConsumerWidget {
return HeartButton(
isLiked: isLikedQuery.data ?? false,
tooltip: isLikedQuery.data ?? false
? "Remove from Favorite"
: "Add to Favorite",
? context.l10n.remove_from_favorites
: context.l10n.save_as_favorite,
color: color?.titleTextColor,
onPressed: isLikedQuery.hasData
? () {
Expand Down Expand Up @@ -216,7 +219,9 @@ class AlbumHeartButton extends HookConsumerWidget {

return HeartButton(
isLiked: isLiked,
tooltip: isLiked ? "Remove from Favorite" : "Add to Favorite",
tooltip: isLiked
? context.l10n.remove_from_favorites
: context.l10n.save_as_favorite,
onPressed: albumIsSaved.hasData
? () {
toggleAlbumLike.mutate(isLiked);
Expand Down
14 changes: 9 additions & 5 deletions lib/components/shared/track_table/track_collection_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:spotube/components/shared/shimmers/shimmer_track_tile.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/components/shared/track_table/tracks_table_view.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/use_custom_status_bar_color.dart';
import 'package:spotube/hooks/use_palette_color.dart';
import 'package:spotube/models/logger.dart';
Expand Down Expand Up @@ -80,7 +81,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
),
if (heartBtn != null && auth != null) heartBtn!,
IconButton(
tooltip: "Shuffle",
tooltip: context.l10n.shuffle,
icon: Icon(
SpotubeIcons.shuffle,
color: color?.titleTextColor,
Expand Down Expand Up @@ -166,7 +167,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
onChanged: (value) => searchText.value = value,
style: TextStyle(color: color?.titleTextColor),
decoration: InputDecoration(
hintText: "Search tracks...",
hintText: context.l10n.search_tracks,
hintStyle: TextStyle(color: color?.titleTextColor),
border: theme.inputDecorationTheme.border?.copyWith(
borderSide: BorderSide(
Expand Down Expand Up @@ -211,7 +212,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
if (kIsMobile)
CompactSearch(
onChanged: (value) => searchText.value = value,
placeholder: "Search tracks...",
placeholder: context.l10n.search_tracks,
iconColor: color?.titleTextColor,
),
if (collapsed.value) ...buttons,
Expand Down Expand Up @@ -287,7 +288,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
),
if (album != null)
Text(
"${AlbumType.from(album?.albumType).formatted}Released${DateTime.tryParse(
"${AlbumType.from(album?.albumType).formatted}${context.l10n.released}${DateTime.tryParse(
album?.releaseDate ?? "",
)?.year}",
style:
Expand Down Expand Up @@ -325,7 +326,10 @@ class TrackCollectionView<T> extends HookConsumerWidget {
return const ShimmerTrackTile();
} else if (tracksSnapshot.hasError) {
return SliverToBoxAdapter(
child: Text("Error ${tracksSnapshot.error}"));
child: Text(
context.l10n.error(tracksSnapshot.error ?? ""),
),
);
}

return TracksTableView(
Expand Down
68 changes: 40 additions & 28 deletions lib/components/shared/track_table/track_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/shared/heart_button.dart';
import 'package:spotube/components/shared/links/link_text.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/use_breakpoints.dart';
import 'package:spotube/models/logger.dart';
import 'package:spotube/provider/authentication_provider.dart';
Expand Down Expand Up @@ -90,7 +91,7 @@ class TrackTile extends HookConsumerWidget {
width: 300,
behavior: SnackBarBehavior.floating,
content: Text(
"Copied $data to clipboard",
context.l10n.copied_to_clipboard(data),
textAlign: TextAlign.center,
),
),
Expand All @@ -114,19 +115,20 @@ class TrackTile extends HookConsumerWidget {
final playlistsCheck = useState(<String, bool>{});
return AlertDialog(
title: Text(
"Add `${track.value.name}` to following Playlists",
context.l10n
.add_to_following_playlists(track.value.name!),
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
actions: [
OutlinedButton(
child: const Text("Cancel"),
child: Text(context.l10n.cancel),
onPressed: () => Navigator.pop(context),
),
FilledButton(
child: const Text("Add"),
child: Text(context.l10n.add),
onPressed: () async {
final selectedPlaylists = playlistsCheck
.value.entries
Expand Down Expand Up @@ -263,7 +265,7 @@ class TrackTile extends HookConsumerWidget {
if (isBlackListed) ...[
const SizedBox(width: 5),
Text(
"Blacklisted",
context.l10n.blacklisted,
style: TextStyle(
color: Colors.red[400],
fontSize: 12,
Expand Down Expand Up @@ -307,7 +309,7 @@ class TrackTile extends HookConsumerWidget {
PopupMenuButton(
icon: const Icon(SpotubeIcons.moreHorizontal),
position: PopupMenuPosition.under,
tooltip: "More options",
tooltip: context.l10n.more_actions,
itemBuilder: (context) {
return [
if (!playlistQueueNotifier.isTrackOnQueue(track.value)) ...[
Expand All @@ -318,14 +320,15 @@ class TrackTile extends HookConsumerWidget {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Added ${track.value.name} to queue",
context.l10n
.added_track_to_queue(track.value.name!),
),
),
);
},
child: const ListTile(
leading: Icon(SpotubeIcons.queueAdd),
title: Text("Add to Queue"),
child: ListTile(
leading: const Icon(SpotubeIcons.queueAdd),
title: Text(context.l10n.add_to_queue),
),
),
PopupMenuItem(
Expand All @@ -334,14 +337,16 @@ class TrackTile extends HookConsumerWidget {
playlistQueueNotifier.playNext([track.value]);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content:
Text("${track.value.name} will play next"),
content: Text(
context.l10n
.track_will_play_next(track.value.name!),
),
),
);
},
child: const ListTile(
leading: Icon(SpotubeIcons.lightning),
title: Text("Play next"),
child: ListTile(
leading: const Icon(SpotubeIcons.lightning),
title: Text(context.l10n.play_next),
),
),
] else
Expand All @@ -354,14 +359,17 @@ class TrackTile extends HookConsumerWidget {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Removed ${track.value.name} from queue"),
context.l10n.removed_track_from_queue(
track.value.name!,
),
),
),
);
},
enabled: playlist?.activeTrack.id != track.value.id,
child: const ListTile(
leading: Icon(SpotubeIcons.queueRemove),
title: Text("Remove from queue"),
child: ListTile(
leading: const Icon(SpotubeIcons.queueRemove),
title: Text(context.l10n.remove_from_queue),
),
),
if (toggler.item3.hasData)
Expand All @@ -378,17 +386,19 @@ class TrackTile extends HookConsumerWidget {
)
: const Icon(SpotubeIcons.heart),
title: Text(
"${toggler.item1 ? "Remove from" : "Save as "} favorite",
toggler.item1
? context.l10n.remove_from_favorites
: context.l10n.save_as_favorite,
),
),
),
if (auth != null)
PopupMenuItem(
padding: EdgeInsets.zero,
onTap: actionAddToPlaylist,
child: const ListTile(
leading: Icon(SpotubeIcons.playlistAdd),
title: Text("Add To playlist"),
child: ListTile(
leading: const Icon(SpotubeIcons.playlistAdd),
title: Text(context.l10n.add_to_playlist),
),
),
if (userPlaylist && auth != null)
Expand All @@ -406,7 +416,7 @@ class TrackTile extends HookConsumerWidget {
child: CircularProgressIndicator(),
)
: const Icon(SpotubeIcons.removeFilled),
title: const Text("Remove from playlist"),
title: Text(context.l10n.remove_from_playlist),
),
),
PopupMenuItem(
Expand All @@ -429,7 +439,9 @@ class TrackTile extends HookConsumerWidget {
iconColor: !isBlackListed ? Colors.red[400] : null,
textColor: !isBlackListed ? Colors.red[400] : null,
title: Text(
"${isBlackListed ? "Remove from" : "Add to"} blacklist",
isBlackListed
? context.l10n.remove_from_blacklist
: context.l10n.add_to_blacklist,
),
),
),
Expand All @@ -438,9 +450,9 @@ class TrackTile extends HookConsumerWidget {
onTap: () {
actionShare(track.value);
},
child: const ListTile(
leading: Icon(SpotubeIcons.share),
title: Text("Share"),
child: ListTile(
leading: const Icon(SpotubeIcons.share),
title: Text(context.l10n.share),
),
)
];
Expand Down

0 comments on commit c55133d

Please sign in to comment.