Adds localization
This commit is contained in:
@@ -12,12 +12,16 @@ import edu.regis.universeplayer.data.Album;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This panel will display information on an album.
|
* This panel will display information on an album.
|
||||||
*/
|
*/
|
||||||
public class AlbumInfo extends JButton
|
public class AlbumInfo extends JButton
|
||||||
{
|
{
|
||||||
|
private static final ResourceBundle langs = ResourceBundle.getBundle("lang.interface", Locale.getDefault());
|
||||||
|
|
||||||
public Album album;
|
public Album album;
|
||||||
public final JLabel artLabel;
|
public final JLabel artLabel;
|
||||||
public final JLabel albumName;
|
public final JLabel albumName;
|
||||||
@@ -38,13 +42,13 @@ public class AlbumInfo extends JButton
|
|||||||
|
|
||||||
this.artLabel = new JLabel();
|
this.artLabel = new JLabel();
|
||||||
this.add(this.artLabel);
|
this.add(this.artLabel);
|
||||||
this.albumName = new JLabel("Album");
|
this.albumName = new JLabel(langs.getString("albumInfo.album"));
|
||||||
this.add(this.albumName);
|
this.add(this.albumName);
|
||||||
this.artists = new JLabel("Artists");
|
this.artists = new JLabel(langs.getString("albumInfo.artists"));
|
||||||
this.add(this.artists);
|
this.add(this.artists);
|
||||||
this.genres = new JLabel("Genres");
|
this.genres = new JLabel(langs.getString("albumInfo.genres"));
|
||||||
this.add(this.genres);
|
this.add(this.genres);
|
||||||
this.year = new JLabel("20XX");
|
this.year = new JLabel(langs.getString("albumInfo.year"));
|
||||||
this.add(this.year);
|
this.add(this.year);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,12 +9,11 @@ import java.awt.event.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.LineBorder;
|
|
||||||
import javax.swing.plaf.LabelUI;
|
|
||||||
|
|
||||||
import edu.regis.universeplayer.ClickListener;
|
|
||||||
import edu.regis.universeplayer.data.CollectionType;
|
import edu.regis.universeplayer.data.CollectionType;
|
||||||
import edu.regis.universeplayer.data.Song;
|
import edu.regis.universeplayer.data.Song;
|
||||||
import edu.regis.universeplayer.data.SongProvider;
|
import edu.regis.universeplayer.data.SongProvider;
|
||||||
@@ -27,6 +26,8 @@ import edu.regis.universeplayer.data.SongProvider;
|
|||||||
*/
|
*/
|
||||||
public class Collections extends JPanel
|
public class Collections extends JPanel
|
||||||
{
|
{
|
||||||
|
private static final ResourceBundle langs = ResourceBundle.getBundle("lang.interface", Locale.getDefault());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of all things interested in knowing when we click a collection.
|
* A list of all things interested in knowing when we click a collection.
|
||||||
*/
|
*/
|
||||||
@@ -44,35 +45,35 @@ public class Collections extends JPanel
|
|||||||
this.setFocusable(true);
|
this.setFocusable(true);
|
||||||
this.setFocusCycleRoot(true);
|
this.setFocusCycleRoot(true);
|
||||||
|
|
||||||
this.add(defaultLabel = label = this.createButton("All Songs"));
|
this.add(defaultLabel = label = this.createButton(langs.getString("collections.all")));
|
||||||
label.setMnemonic('A');
|
label.setMnemonic('A');
|
||||||
label.addActionListener(mouseEvent -> this
|
label.addActionListener(mouseEvent -> this
|
||||||
.triggerSongDisplayListeners(new ArrayList<>(SongProvider.INSTANCE.getSongs())));
|
.triggerSongDisplayListeners(new ArrayList<>(SongProvider.INSTANCE.getSongs())));
|
||||||
this.add(label = this.createButton("Artists"));
|
this.add(label = this.createButton(langs.getString("collections.artists")));
|
||||||
label.setMnemonic('T');
|
label.setMnemonic('T');
|
||||||
label.addActionListener(mouseEvent -> this
|
label.addActionListener(mouseEvent -> this
|
||||||
.triggerCollectionDisplayListeners(CollectionType.albumArtist, SongProvider.INSTANCE
|
.triggerCollectionDisplayListeners(CollectionType.albumArtist, SongProvider.INSTANCE
|
||||||
.getAlbumArtists()));
|
.getAlbumArtists()));
|
||||||
this.add(label = this.createButton("Albums"));
|
this.add(label = this.createButton(langs.getString("collections.albums")));
|
||||||
label.setMnemonic('B');
|
label.setMnemonic('B');
|
||||||
label.addActionListener(mouseEvent -> this
|
label.addActionListener(mouseEvent -> this
|
||||||
.triggerCollectionDisplayListeners(CollectionType.album, SongProvider.INSTANCE
|
.triggerCollectionDisplayListeners(CollectionType.album, SongProvider.INSTANCE
|
||||||
.getAlbums()));
|
.getAlbums()));
|
||||||
this.add(label = this.createButton("Genres"));
|
this.add(label = this.createButton(langs.getString("collections.genres")));
|
||||||
label.setMnemonic('G');
|
label.setMnemonic('G');
|
||||||
label.addActionListener(mouseEvent -> this
|
label.addActionListener(mouseEvent -> this
|
||||||
.triggerCollectionDisplayListeners(CollectionType.genre, SongProvider.INSTANCE
|
.triggerCollectionDisplayListeners(CollectionType.genre, SongProvider.INSTANCE
|
||||||
.getGenres()));
|
.getGenres()));
|
||||||
this.add(label = this.createButton("Years"));
|
this.add(label = this.createButton(langs.getString("collections.years")));
|
||||||
label.setMnemonic('Y');
|
label.setMnemonic('Y');
|
||||||
label.addActionListener(mouseEvent -> this
|
label.addActionListener(mouseEvent -> this
|
||||||
.triggerCollectionDisplayListeners(CollectionType.year, SongProvider.INSTANCE
|
.triggerCollectionDisplayListeners(CollectionType.year, SongProvider.INSTANCE
|
||||||
.getYears()));
|
.getYears()));
|
||||||
this.add(new JLabel("\u23AF".repeat(6)));
|
this.add(new JLabel("\u23AF".repeat(6)));
|
||||||
this.add(label = this.createButton("Playlists"));
|
this.add(label = this.createButton(langs.getString("collections.playlists")));
|
||||||
label.setMnemonic('P');
|
label.setMnemonic('P');
|
||||||
this.add(new JLabel("\u23AF".repeat(6)));
|
this.add(new JLabel("\u23AF".repeat(6)));
|
||||||
this.add(label = this.createButton("Add External Song"));
|
this.add(label = this.createButton(langs.getString("actions.external.add.title")));
|
||||||
label.setMnemonic('E');
|
label.setMnemonic('E');
|
||||||
label.addActionListener(mouseEvent -> this.addNewSong());
|
label.addActionListener(mouseEvent -> this.addNewSong());
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +35,11 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class Interface extends JFrame implements SongDisplayListener, ComponentListener, WindowListener, UpdateListener, FocusListener
|
public class Interface extends JFrame implements SongDisplayListener, ComponentListener, WindowListener, UpdateListener, FocusListener
|
||||||
{
|
{
|
||||||
|
// static {
|
||||||
|
// Locale.setDefault(new Locale("es", "ES"));
|
||||||
|
// }
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Interface.class);
|
private static final Logger logger = LoggerFactory.getLogger(Interface.class);
|
||||||
|
private static final ResourceBundle langs = ResourceBundle.getBundle("lang.interface", Locale.getDefault());
|
||||||
|
|
||||||
private static File dataDir;
|
private static File dataDir;
|
||||||
private static File commDir;
|
private static File commDir;
|
||||||
@@ -129,13 +135,13 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
|
|||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
logger.error("Could not open browser background", e);
|
logger.error("Could not open browser background", e);
|
||||||
JOptionPane.showMessageDialog(inter, e, "Could not open browser background", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(inter, e, langs.getString("error.browser.launch"), JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
logger.error("Could not open browser background", e);
|
logger.error("Could not open browser background", e);
|
||||||
JOptionPane.showMessageDialog(inter != null && inter.isVisible() ? inter : null, e, "Error!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(inter != null && inter.isVisible() ? inter : null, e, langs.getString("error.generic"), JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +221,7 @@ public class Interface extends JFrame implements SongDisplayListener, ComponentL
|
|||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.setTitle("Universal Music Player");
|
this.setTitle(langs.getString("title"));
|
||||||
this.getContentPane().setLayout(new BorderLayout());
|
this.getContentPane().setLayout(new BorderLayout());
|
||||||
this.setFocusable(true);
|
this.setFocusable(true);
|
||||||
this.setFocusCycleRoot(true);
|
this.setFocusCycleRoot(true);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import java.awt.event.FocusAdapter;
|
|||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import java.util.concurrent.Future;
|
|||||||
public class InternetSongDialog extends JDialog
|
public class InternetSongDialog extends JDialog
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(InternetSongDialog.class);
|
private static final Logger logger = LoggerFactory.getLogger(InternetSongDialog.class);
|
||||||
|
private static final ResourceBundle langs = ResourceBundle.getBundle("lang.interface", Locale.getDefault());
|
||||||
|
|
||||||
private final JTextField urlBox;
|
private final JTextField urlBox;
|
||||||
private final JTextField titleBox;
|
private final JTextField titleBox;
|
||||||
@@ -48,7 +51,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
c.anchor = GridBagConstraints.WEST;
|
c.anchor = GridBagConstraints.WEST;
|
||||||
c.insets = new Insets(0, 2, 5, 2);
|
c.insets = new Insets(0, 2, 5, 2);
|
||||||
|
|
||||||
this.getContentPane().add(label = new JLabel("URL"), c);
|
this.getContentPane().add(label = new JLabel(langs.getString("actions.external.add.url")), c);
|
||||||
this.urlBox = new JTextField();
|
this.urlBox = new JTextField();
|
||||||
this.urlBox.addFocusListener(new FocusAdapter()
|
this.urlBox.addFocusListener(new FocusAdapter()
|
||||||
{
|
{
|
||||||
@@ -73,7 +76,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(label = new JLabel("Song Title"), c);
|
this.getContentPane().add(label = new JLabel(langs.getString("actions.external.add.song")), c);
|
||||||
this.titleBox = new JTextField();
|
this.titleBox = new JTextField();
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(this.titleBox, c);
|
this.getContentPane().add(this.titleBox, c);
|
||||||
@@ -81,7 +84,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(label = new JLabel("Album"), c);
|
this.getContentPane().add(label = new JLabel(langs.getString("actions.external.add.album")), c);
|
||||||
this.albumBox = new JTextField();
|
this.albumBox = new JTextField();
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(this.albumBox, c);
|
this.getContentPane().add(this.albumBox, c);
|
||||||
@@ -89,7 +92,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(label = new JLabel("Artists"), c);
|
this.getContentPane().add(label = new JLabel(langs.getString("actions.external.add.artists")), c);
|
||||||
this.artistBox = new JTextField();
|
this.artistBox = new JTextField();
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(this.artistBox, c);
|
this.getContentPane().add(this.artistBox, c);
|
||||||
@@ -97,7 +100,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(label = new JLabel("Genre"), c);
|
this.getContentPane().add(label = new JLabel(langs.getString("actions.external.add.genre")), c);
|
||||||
this.genreBox = new JTextField();
|
this.genreBox = new JTextField();
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
this.getContentPane().add(this.genreBox, c);
|
this.getContentPane().add(this.genreBox, c);
|
||||||
@@ -106,11 +109,11 @@ public class InternetSongDialog extends JDialog
|
|||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = ++y;
|
c.gridy = ++y;
|
||||||
JButton cancelButton = new JButton("Cancel");
|
JButton cancelButton = new JButton(langs.getString("actions.cancel"));
|
||||||
cancelButton.addActionListener(e -> this.dispose());
|
cancelButton.addActionListener(e -> this.dispose());
|
||||||
this.getContentPane().add(cancelButton, c);
|
this.getContentPane().add(cancelButton, c);
|
||||||
c.gridx = 1;
|
c.gridx = 1;
|
||||||
JButton addButton = new JButton("Add");
|
JButton addButton = new JButton(langs.getString("actions.add"));
|
||||||
addButton.addActionListener(e -> this.confirm());
|
addButton.addActionListener(e -> this.confirm());
|
||||||
this.getContentPane().add(addButton, c);
|
this.getContentPane().add(addButton, c);
|
||||||
|
|
||||||
@@ -151,7 +154,7 @@ public class InternetSongDialog extends JDialog
|
|||||||
catch (InterruptedException | ExecutionException e)
|
catch (InterruptedException | ExecutionException e)
|
||||||
{
|
{
|
||||||
logger.error("Could not evaluate song", e);
|
logger.error("Could not evaluate song", e);
|
||||||
JOptionPane.showMessageDialog(InternetSongDialog.this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(InternetSongDialog.this, e.getMessage(), langs.getString("error.generic"), JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,10 +17,13 @@ import java.awt.event.FocusAdapter;
|
|||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.Formatter;
|
import java.util.Formatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class QueueList extends JPanel implements Queue.SongChangeListener, Queue.QueueChangeListener
|
public class QueueList extends JPanel implements Queue.SongChangeListener, Queue.QueueChangeListener
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(QueueList.class);
|
private static final Logger logger = LoggerFactory.getLogger(QueueList.class);
|
||||||
|
private static final ResourceBundle langs = ResourceBundle.getBundle("lang.interface", Locale.getDefault());
|
||||||
|
|
||||||
final JPanel header;
|
final JPanel header;
|
||||||
final ScrollablePanel songList;
|
final ScrollablePanel songList;
|
||||||
@@ -42,8 +45,8 @@ public class QueueList extends JPanel implements Queue.SongChangeListener, Queue
|
|||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = 0;
|
c.gridy = 0;
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
header.add(new JLabel(" ".repeat(20) + "Queue" + " ".repeat(20)), c);
|
header.add(new JLabel(" ".repeat(20) + langs.getString("interface.queue.title") + " ".repeat(20)), c);
|
||||||
this.clearButton = new JButton("Clear");
|
this.clearButton = new JButton(langs.getString("actions.clear"));
|
||||||
this.clearButton.addActionListener(e -> Queue.getInstance().clear());
|
this.clearButton.addActionListener(e -> Queue.getInstance().clear());
|
||||||
c.gridy = 1;
|
c.gridy = 1;
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
@@ -229,8 +232,8 @@ public class QueueList extends JPanel implements Queue.SongChangeListener, Queue
|
|||||||
{
|
{
|
||||||
public SongMenu(Song song, Queue queue)
|
public SongMenu(Song song, Queue queue)
|
||||||
{
|
{
|
||||||
final JMenuItem play = new JMenuItem("Play");
|
final JMenuItem play = new JMenuItem(langs.getString("actions.play"));
|
||||||
final JMenuItem remove = new JMenuItem("Remove");
|
final JMenuItem remove = new JMenuItem(langs.getString("actions.remove"));
|
||||||
|
|
||||||
play.addActionListener(e -> queue.skipToSong(queue.indexOf(song)));
|
play.addActionListener(e -> queue.skipToSong(queue.indexOf(song)));
|
||||||
remove.addActionListener(e -> queue.remove(song));
|
remove.addActionListener(e -> queue.remove(song));
|
||||||
|
|||||||
37
interface/src/main/resources/lang/interface.properties
Normal file
37
interface/src/main/resources/lang/interface.properties
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
title=Universal Music Player
|
||||||
|
|
||||||
|
albumInfo.album=Album
|
||||||
|
albumInfo.artists=Artists
|
||||||
|
albumInfo.genres=Genres
|
||||||
|
albumInfo.year=Year
|
||||||
|
|
||||||
|
collections.all=All Songs
|
||||||
|
collections.artists=Artists
|
||||||
|
collections.albums=Albums
|
||||||
|
collections.genres=Genres
|
||||||
|
collections.years=Years
|
||||||
|
collections.playlists=Playlists
|
||||||
|
|
||||||
|
interface.queue.title=Queue
|
||||||
|
|
||||||
|
actions.apply=Apply
|
||||||
|
actions.confirm=O.K.
|
||||||
|
actions.add=Add
|
||||||
|
actions.remove=Remove
|
||||||
|
actions.cancel=Cancel
|
||||||
|
actions.clear=Clear
|
||||||
|
actions.play=Play
|
||||||
|
actions.pause=Pause
|
||||||
|
actions.skipNext=Next
|
||||||
|
actions.skipPrev=Previous
|
||||||
|
actions.stop=Stop
|
||||||
|
|
||||||
|
actions.external.add.title=Add External Song
|
||||||
|
actions.external.add.url=URL
|
||||||
|
actions.external.add.song=Song Title
|
||||||
|
actions.external.add.album=Album
|
||||||
|
actions.external.add.artists=Artists
|
||||||
|
actions.external.add.genre=Genre
|
||||||
|
|
||||||
|
error.generic=Error!
|
||||||
|
error.browser.launch=Could not open browser background
|
||||||
37
interface/src/main/resources/lang/interface_es.properties
Normal file
37
interface/src/main/resources/lang/interface_es.properties
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
title=Reproductor de música universal
|
||||||
|
|
||||||
|
albumInfo.album=Álbum
|
||||||
|
albumInfo.artists=Artistas
|
||||||
|
albumInfo.genres=Géneros
|
||||||
|
albumInfo.year=Año
|
||||||
|
|
||||||
|
collections.all=Todas las canciones
|
||||||
|
collections.artists=Artistas
|
||||||
|
collections.albums=Álbums
|
||||||
|
collections.genres=Géneros
|
||||||
|
collections.years=Años
|
||||||
|
collections.playlists=Listas
|
||||||
|
|
||||||
|
interface.queue.title=Queue
|
||||||
|
|
||||||
|
actions.apply=Aplique
|
||||||
|
actions.confirm=Vale
|
||||||
|
actions.add=Añadir
|
||||||
|
actions.remove=Eliminar
|
||||||
|
actions.cancel=Cancelar
|
||||||
|
actions.clear=Claro
|
||||||
|
actions.play=Reproducir
|
||||||
|
actions.pause=Pausa
|
||||||
|
actions.skipNext=Siguiente
|
||||||
|
actions.skipPrev=Anteriormente
|
||||||
|
actions.stop=Detener
|
||||||
|
|
||||||
|
actions.external.add.title=Añadir canción externa
|
||||||
|
actions.external.add.url=URL
|
||||||
|
actions.external.add.song=Título
|
||||||
|
actions.external.add.album=Álbum
|
||||||
|
actions.external.add.artists=Artistas
|
||||||
|
actions.external.add.genre=Género
|
||||||
|
|
||||||
|
error.generic=¡Error!
|
||||||
|
error.browser.launch=No se puede abrir el fondo del navegador
|
||||||
Reference in New Issue
Block a user