Skip to content

Commit

Permalink
Make some hard coded strings translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
josuigoa committed Jun 13, 2024
1 parent f81219e commit b1ec588
Show file tree
Hide file tree
Showing 31 changed files with 246 additions and 101 deletions.
6 changes: 3 additions & 3 deletions lib/collections/language_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ abstract class LanguageLocals {
// ),
"eu": const ISOLanguageName(
name: "Basque",
nativeName: "euskara",
nativeName: "Euskara",
),
// "be": const ISOLanguageName(
// name: "Belarusian",
Expand Down Expand Up @@ -354,8 +354,8 @@ abstract class LanguageLocals {
// nativeName: "KiKongo",
// ),
"ko": const ISOLanguageName(
name: "Korean",
nativeName: "한국어 (韓國語), 조선말 (朝鮮語)",
name: "Korean",
nativeName: "한국어 (韓國語), 조선말 (朝鮮語)",
),
// "ku": const ISOLanguageName(
// name: "Kurdish",
Expand Down
5 changes: 3 additions & 2 deletions lib/components/home/sections/feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/pages/home/feed/feed_section.dart';
import 'package:spotube/provider/spotify/views/home.dart';
import 'package:spotube/utils/service_utils.dart';
Expand Down Expand Up @@ -33,14 +34,14 @@ class HomePageFeedSection extends HookConsumerWidget {
else if (item.playlist != null)
item.playlist!.asPlaylist
],
title: Text(section.title ?? "No Titel"),
title: Text(section.title ?? context.l10n.no_title),
hasNextPage: false,
isLoadingNextPage: false,
onFetchMore: () {},
titleTrailing: Directionality(
textDirection: TextDirection.rtl,
child: TextButton.icon(
label: const Text("Browse More"),
label: Text(context.l10n.browse_more),
icon: const Icon(SpotubeIcons.angleRight),
onPressed: () => ServiceUtils.pushNamed(
context,
Expand Down
3 changes: 2 additions & 1 deletion lib/components/home/sections/friends.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:spotube/collections/fake.dart';
import 'package:spotube/components/home/sections/friends/friend_item.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/utils/use_breakpoint_value.dart';
import 'package:spotube/models/spotify_friends.dart';
import 'package:spotube/provider/authentication_provider.dart';
Expand Down Expand Up @@ -73,7 +74,7 @@ class HomePageFriendsSection extends HookConsumerWidget {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Friends',
context.l10n.friends,
style: Theme.of(context).textTheme.titleMedium,
),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/components/home/sections/recent.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/provider/history/recent.dart';
import 'package:spotube/provider/history/state.dart';

Expand All @@ -16,7 +17,7 @@ class HomeRecentlyPlayedSection extends HookConsumerWidget {
}

return HorizontalPlaybuttonCardView(
title: const Text('Recently Played'),
title: Text(context.l10n.recently_played),
items: [
for (final item in history)
if (item is PlaybackHistoryPlaylist)
Expand Down
3 changes: 2 additions & 1 deletion lib/components/player/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class PlayerView extends HookConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AutoSizeText(
currentTrack?.name ?? "Not playing",
currentTrack?.name ??
context.l10n.not_playing,
style: TextStyle(
color: titleTextColor,
fontSize: 22,
Expand Down
5 changes: 3 additions & 2 deletions lib/components/playlist/playlist_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/shared/dialogs/select_device_dialog.dart';
import 'package:spotube/components/shared/playbutton_card.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/extensions/image.dart';
import 'package:spotube/models/connect/connect.dart';
import 'package:spotube/pages/playlist/playlist.dart';
Expand Down Expand Up @@ -132,8 +133,8 @@ class PlaylistCard extends HookConsumerWidget {
historyNotifier.addPlaylists([playlist]);
if (context.mounted) {
final snackbar = SnackBar(
content:
Text("Added ${fetchedInitialTracks.length} tracks to queue"),
content: Text(context.l10n
.added_num_tracks_to_queue(fetchedInitialTracks.length)),
action: SnackBarAction(
label: "Undo",
onPressed: () {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/playlist/playlist_create_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PlaylistCreateDialog extends HookConsumerWidget {
scaffold.showSnackBar(
SnackBar(
content: Text(
l10n.error(error.message ?? "Epic failure!"),
l10n.error(error.message ?? context.l10n.epic_failure),
style: theme.textTheme.bodyMedium!.copyWith(
color: theme.colorScheme.onError,
),
Expand Down
13 changes: 7 additions & 6 deletions lib/components/root/update_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:spotube/components/shared/links/anchor_button.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:spotube/extensions/context.dart';
import 'package:version/version.dart';

class RootAppUpdateDialog extends StatelessWidget {
Expand All @@ -16,10 +17,10 @@ class RootAppUpdateDialog extends StatelessWidget {
const url = "https://spotube.krtirtho.dev/downloads";
const nightlyUrl = "https://spotube.krtirtho.dev/downloads/nightly";
return AlertDialog(
title: const Text("Spotube has an update"),
title: Text(context.l10n.spotube_has_an_update),
actions: [
FilledButton(
child: const Text("Download Now"),
child: Text(context.l10n.download_now),
onPressed: () => launchUrlString(
nightlyBuildNum != null ? nightlyUrl : url,
mode: LaunchMode.externalApplication,
Expand All @@ -31,16 +32,16 @@ class RootAppUpdateDialog extends StatelessWidget {
children: [
Text(
nightlyBuildNum != null
? "Spotube Nightly $nightlyBuildNum has been released"
: "Spotube v$version has been released",
? context.l10n.nightly_version(nightlyBuildNum!)
: context.l10n.release_version(version!),
),
if (nightlyBuildNum == null)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Read the latest "),
Text(context.l10n.read_the_latest),
AnchorButton(
"release notes",
context.l10n.release_notes,
style: const TextStyle(color: Colors.blue),
onTap: () => launchUrlString(
url,
Expand Down
7 changes: 4 additions & 3 deletions lib/components/settings/color_scheme_picker_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/extensions/context.dart';

import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
import 'package:system_theme/system_theme.dart';
Expand Down Expand Up @@ -69,17 +70,17 @@ class ColorSchemePickerDialog extends HookConsumerWidget {
}

return AlertDialog(
title: const Text("Pick color scheme"),
title: Text(context.l10n.pick_color_scheme),
actions: [
OutlinedButton(
child: const Text("Cancel"),
child: Text(context.l10n.cancel),
onPressed: () {
Navigator.pop(context);
},
),
FilledButton(
onPressed: onOk,
child: const Text("Save"),
child: Text(context.l10n.save),
),
],
content: SizedBox(
Expand Down
9 changes: 3 additions & 6 deletions lib/components/shared/dialogs/select_device_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ class SelectDeviceDialog extends HookConsumerWidget {
final remoteService = connectClients.asData!.value.resolvedService!;

return AlertDialog(
title: const Text("Choose the device:"),
title: Text(context.l10n.choose_the_device),
insetPadding: const EdgeInsets.all(16),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"There are multiple device connected.\n"
"Choose the device you want this action to take place",
),
Text(context.l10n.multiple_device_connected),
RadioListTile.adaptive(
title: Text(remoteService.name),
value: true,
Expand All @@ -33,7 +30,7 @@ class SelectDeviceDialog extends HookConsumerWidget {
},
),
RadioListTile.adaptive(
title: const Text("This Device"),
title: Text(context.l10n.this_device),
value: false,
groupValue: isRemoteService.value,
onChanged: (value) {
Expand Down
5 changes: 3 additions & 2 deletions lib/components/shared/fallbacks/not_found.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:spotube/collections/assets.gen.dart';
import 'package:spotube/extensions/context.dart';

class NotFound extends StatelessWidget {
final bool vertical;
Expand All @@ -18,9 +19,9 @@ class NotFound extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Nothing found", style: theme.textTheme.titleLarge),
Text(context.l10n.nothing_found, style: theme.textTheme.titleLarge),
Text(
"The box is empty",
context.l10n.the_box_is_empty,
style: theme.textTheme.titleMedium,
),
],
Expand Down
3 changes: 2 additions & 1 deletion lib/components/shared/playbutton_card.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/shared/hover_builder.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/extensions/constrains.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/hooks/utils/use_breakpoint_value.dart';
import 'package:spotube/hooks/utils/use_brightness_value.dart';

Expand Down Expand Up @@ -137,7 +138,7 @@ class PlaybuttonCard extends HookWidget {
),
if (isHovered)
Text(
"Owned by you",
context.l10n.owned_by_you,
style: theme.textTheme.bodySmall?.copyWith(
color: Colors.white,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class TrackViewHeaderActions extends HookConsumerWidget {

final auth = ref.watch(authenticationProvider);

final copiedText =
context.l10n.copied_shareurl_to_clipboard(props.shareUrl);

return Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -48,7 +51,7 @@ class TrackViewHeaderActions extends HookConsumerWidget {
width: 300,
behavior: SnackBarBehavior.floating,
content: Text(
"Copied ${props.shareUrl} to clipboard",
copiedText,
textAlign: TextAlign.center,
),
),
Expand Down
23 changes: 12 additions & 11 deletions lib/components/stats/summary/summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/formatters.dart';
import 'package:spotube/components/stats/summary/summary_card.dart';
import 'package:spotube/extensions/constrains.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/pages/stats/albums/albums.dart';
import 'package:spotube/pages/stats/artists/artists.dart';
import 'package:spotube/pages/stats/fees/fees.dart';
Expand Down Expand Up @@ -40,17 +41,17 @@ class StatsPageSummarySection extends HookConsumerWidget {
delegate: SliverChildListDelegate([
SummaryCard(
title: summary.duration.inMinutes.toDouble(),
unit: "minutes",
description: 'Listened to music',
unit: context.l10n.summary_minutes,
description: context.l10n.summary_listened_to_music,
color: Colors.purple,
onTap: () {
ServiceUtils.pushNamed(context, StatsMinutesPage.name);
},
),
SummaryCard(
title: summary.tracks.toDouble(),
unit: "songs",
description: 'Streamed overall',
unit: context.l10n.summary_songs,
description: context.l10n.summary_streamed_overall,
color: Colors.lightBlue,
onTap: () {
ServiceUtils.pushNamed(context, StatsStreamsPage.name);
Expand All @@ -59,34 +60,34 @@ class StatsPageSummarySection extends HookConsumerWidget {
SummaryCard.unformatted(
title: usdFormatter.format(summary.fees.toDouble()),
unit: "",
description: 'Owed to artists\nthis month',
description: context.l10n.summary_owed_to_artists,
color: Colors.green,
onTap: () {
ServiceUtils.pushNamed(context, StatsStreamFeesPage.name);
},
),
SummaryCard(
title: summary.artists.toDouble(),
unit: "artist's",
description: 'Music reached you',
unit: context.l10n.summary_artists,
description: context.l10n.summary_music_reached_you,
color: Colors.yellow,
onTap: () {
ServiceUtils.pushNamed(context, StatsArtistsPage.name);
},
),
SummaryCard(
title: summary.albums.toDouble(),
unit: "full albums",
description: 'Got your love',
unit: context.l10n.summary_full_albums,
description: context.l10n.summary_got_your_love,
color: Colors.pink,
onTap: () {
ServiceUtils.pushNamed(context, StatsAlbumsPage.name);
},
),
SummaryCard(
title: summary.playlists.toDouble(),
unit: "playlists",
description: 'Were on repeat',
unit: context.l10n.summary_playlists,
description: context.l10n.summary_were_on_repeat,
color: Colors.teal,
onTap: () {
ServiceUtils.pushNamed(context, StatsPlaylistsPage.name);
Expand Down
4 changes: 3 additions & 1 deletion lib/components/stats/top/albums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/formatters.dart';
import 'package:spotube/components/stats/common/album_item.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/provider/history/top.dart';

class TopAlbums extends HookConsumerWidget {
Expand All @@ -20,7 +21,8 @@ class TopAlbums extends HookConsumerWidget {
return StatsAlbumItem(
album: album.album,
info: Text(
"${compactNumberFormatter.format(album.count)} plays",
context.l10n
.count_plays(compactNumberFormatter.format(album.count)),
),
);
},
Expand Down
6 changes: 5 additions & 1 deletion lib/components/stats/top/artists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/formatters.dart';
import 'package:spotube/components/stats/common/artist_item.dart';
import 'package:spotube/extensions/context.dart';
import 'package:spotube/provider/history/top.dart';

class TopArtists extends HookConsumerWidget {
Expand All @@ -19,7 +20,10 @@ class TopArtists extends HookConsumerWidget {
final artist = artists[index];
return StatsArtistItem(
artist: artist.artist,
info: Text("${compactNumberFormatter.format(artist.count)} plays"),
info: Text(
context.l10n
.count_plays(compactNumberFormatter.format(artist.count)),
),
);
},
);
Expand Down
Loading

0 comments on commit b1ec588

Please sign in to comment.