From 79921970e253714e6c6797d9cd1a5288328aff3e Mon Sep 17 00:00:00 2001 From: wjsc Date: Sat, 24 Feb 2018 13:27:52 -0300 Subject: [PATCH] MultiLanguage Support && ReactJS 16.2.0 --- package.json | 4 +-- src/components/AlbumTab/AlbumTab.js | 6 ++-- src/components/ArtistTab/ArtistTab.js | 5 ++-- src/components/FavoritesTab/FavoritesTab.js | 7 +++-- src/components/PlayerTab/PlayerTab.js | 5 ++-- src/components/RandomTab/RandomTab.js | 5 ++-- src/components/SearchTab/SearchTab.css | 19 ++++++------- src/components/SearchTab/SearchTab.js | 3 +- src/components/Sidebar.js | 31 +++++++++++++++++---- src/components/SidebarElement.js | 2 +- src/components/UserAccess/SignInScreen.js | 20 ++++++------- src/components/lang/Translate.js | 8 ++++++ src/components/lang/en.js | 23 +++++++++++++++ src/components/lang/es.js | 23 +++++++++++++++ 14 files changed, 117 insertions(+), 44 deletions(-) create mode 100644 src/components/lang/Translate.js create mode 100644 src/components/lang/en.js create mode 100644 src/components/lang/es.js diff --git a/package.json b/package.json index 829a029..4b5b7ab 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "private": true, "dependencies": { "firebase": "^4.8.1", - "react": "^15.6.1", - "react-dom": "^15.6.1", + "react": "^16.2.0", + "react-dom": "^16.2.0", "react-firebaseui": "^1.0.10", "react-router": "^4.1.1", "react-router-dom": "^4.1.1", diff --git a/src/components/AlbumTab/AlbumTab.js b/src/components/AlbumTab/AlbumTab.js index d13015f..4828545 100644 --- a/src/components/AlbumTab/AlbumTab.js +++ b/src/components/AlbumTab/AlbumTab.js @@ -1,5 +1,6 @@ import React from 'react'; import './AlbumTab.css'; +import {Translate} from '../lang/Translate'; import {playerLink} from '../playerLink'; import Track from '../Track'; import AlbumCover from '../AlbumCover'; @@ -52,9 +53,8 @@ class AlbumTab extends React.Component {
{this.state.album.title}
-
playerLink.playTracks(this.state.tracks)}> - Play +
playerLink.playTracks(this.state.tracks)}> +
diff --git a/src/components/ArtistTab/ArtistTab.js b/src/components/ArtistTab/ArtistTab.js index f4749d1..4bd6001 100644 --- a/src/components/ArtistTab/ArtistTab.js +++ b/src/components/ArtistTab/ArtistTab.js @@ -1,5 +1,6 @@ import React from 'react'; import './ArtistTab.css'; +import {Translate} from '../lang/Translate'; import {playerLink} from '../playerLink'; import ArtistTabAlbum from './ArtistTabAlbum'; import {fetchArtist, fetchAlbumsByArtist, fetchTracksByArtist, checkFavorites} from '../../calls.js'; @@ -41,12 +42,12 @@ class ArtistTab extends React.Component { {this.state.artist.name}
playerLink.playTracks(this.state.tracks)}> - Play +
- {this.state.albums ? this.state.albums.length : 0} albums indexed + {this.state.albums ? this.state.albums.length : 0}
{this.renderAlbums()} diff --git a/src/components/FavoritesTab/FavoritesTab.js b/src/components/FavoritesTab/FavoritesTab.js index 6d2b6fa..997a625 100644 --- a/src/components/FavoritesTab/FavoritesTab.js +++ b/src/components/FavoritesTab/FavoritesTab.js @@ -1,5 +1,6 @@ import React from 'react'; import './FavoritesTab.css'; +import {Translate} from '../lang/Translate'; import {config} from '../../config/default.js'; import {playerLink} from '../playerLink'; import Track from '../Track'; @@ -28,15 +29,15 @@ class FavoritesTab extends React.Component {
- Favorites +
playerLink.playTracks(this.state.tracks)}> - Play +
- {this.state.tracks.length} tracks in Favorites + {this.state.tracks.length}
{this.renderTracks()} diff --git a/src/components/PlayerTab/PlayerTab.js b/src/components/PlayerTab/PlayerTab.js index 0fd837e..91f4a3a 100644 --- a/src/components/PlayerTab/PlayerTab.js +++ b/src/components/PlayerTab/PlayerTab.js @@ -1,5 +1,6 @@ import React from 'react'; import './PlayerTab.css'; +import {Translate} from '../lang/Translate'; import {config} from '../../config/default.js'; import Track from '../Track'; import {playerLink} from '../playerLink'; @@ -46,8 +47,8 @@ class PlayerTab extends React.Component { return (
-
History
-
Next
+
+
{this.renderTracks(this.state.tracks)} diff --git a/src/components/RandomTab/RandomTab.js b/src/components/RandomTab/RandomTab.js index ad5c9a4..ca8483b 100644 --- a/src/components/RandomTab/RandomTab.js +++ b/src/components/RandomTab/RandomTab.js @@ -1,6 +1,7 @@ import React from 'react'; import './RandomTab.css'; import {config} from '../../config/default.js'; +import {Translate} from '../lang/Translate'; import RandomTabArtist from './RandomTabArtist'; import RandomTabAlbum from './RandomTabAlbum'; import {fetchPaginatedArtists, fetchPaginatedAlbums} from '../../calls'; @@ -34,13 +35,13 @@ class RandomTab extends React.Component {
-
Albums
+
{this.renderAlbums()}
-
Artists
+
{this.renderArtists()}
diff --git a/src/components/SearchTab/SearchTab.css b/src/components/SearchTab/SearchTab.css index 713bff7..28f230e 100644 --- a/src/components/SearchTab/SearchTab.css +++ b/src/components/SearchTab/SearchTab.css @@ -1,14 +1,9 @@ .search_tab{ } -.search_tab .banner{ - background-color: #0c0c0c; - margin-bottom: 30px; -} - .search_tab .banner .search{ padding: 10px; - width: 50%; + width: 70%; border-radius: 5px; border: none; background-color: #121314; @@ -17,6 +12,11 @@ margin-bottom: 25px; margin-left: 30px; margin-top: 30px; + margin-right: 30px; +} + +.search_tab .banner .search:focus{ + outline: none; } .search_tab .all-results .title{ font-weight: bold; @@ -145,12 +145,9 @@ float:right; } @media (max-width: 800px) { - .search_tab .banner { - margin: 25px; - } .search_tab .banner .search { - width: auto; - padding: 10px; + width: 100vw; + padding: 15px; margin: 0; } .search_tab .all-results { diff --git a/src/components/SearchTab/SearchTab.js b/src/components/SearchTab/SearchTab.js index 0391c89..b3092b9 100644 --- a/src/components/SearchTab/SearchTab.js +++ b/src/components/SearchTab/SearchTab.js @@ -1,5 +1,6 @@ import React from 'react'; import './SearchTab.css'; +import {translate} from '../lang/Translate'; import SearchTabArtist from './SearchTabArtist'; import SearchTabAlbum from './SearchTabAlbum'; import Track from '../Track'; @@ -42,7 +43,7 @@ class SearchTab extends React.Component { return (
- +
{this.renderResults()}
diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 9aa0c01..37ae768 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -1,5 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom' +import {Translate} from './lang/Translate'; import SidebarElement from './SidebarElement'; import {userLink} from './userLink'; @@ -7,11 +8,31 @@ class Sidebar extends React.Component { render() { return (
- - - - - + + + + + + + + + + + + + + + + + + + + + + + + +
); } diff --git a/src/components/SidebarElement.js b/src/components/SidebarElement.js index 8e344e2..7c05a66 100644 --- a/src/components/SidebarElement.js +++ b/src/components/SidebarElement.js @@ -5,7 +5,7 @@ class SidebarElement extends React.Component { return (
- {this.props.text} + {this.props.children}
); } diff --git a/src/components/UserAccess/SignInScreen.js b/src/components/UserAccess/SignInScreen.js index 007b914..ca440b3 100644 --- a/src/components/UserAccess/SignInScreen.js +++ b/src/components/UserAccess/SignInScreen.js @@ -2,6 +2,7 @@ import {config} from '../../config/default.js'; import React from 'react'; import { FirebaseAuth } from 'react-firebaseui'; import firebase from 'firebase'; +import {Translate} from '../lang/Translate'; import {userLink} from '../userLink'; import './firebaseui-overrides.global.css'; import './UserAccess.css'; @@ -11,18 +12,13 @@ firebase.initializeApp(config.firebase); class SignInScreen extends React.Component { - // Configure FirebaseUI. uiConfig = { - // Popup signin flow rather than redirect flow. - // redirect || popup signInFlow: 'redirect', - // We will display Google and Facebook as auth providers. signInOptions: [ firebase.auth.GoogleAuthProvider.PROVIDER_ID, firebase.auth.FacebookAuthProvider.PROVIDER_ID, firebase.auth.TwitterAuthProvider.PROVIDER_ID ], - // Sets the CatalogueApp `signedIn` state property to `true` once signed in. callbacks: { signInSuccess: userLink.signInSuccessCallback } @@ -32,18 +28,18 @@ class SignInScreen extends React.Component { return (
-

Catalogue Music

+

-

Access

-

Log in with your social network of choice and start playing with zero cost from now and forever.

-

Artists

-

We are working to involve the artists and collaborate with them in reaching their audience. We believe in the possibility of a self-sustainable platform and in the commitment between users and musicians.

-

Technology

-

Our goal is to offer a premium quality service with minimum latency and cutting-edge technology.

+

+

+

+

+

+

https://github.com/wjsc
diff --git a/src/components/lang/Translate.js b/src/components/lang/Translate.js new file mode 100644 index 0000000..8c427e8 --- /dev/null +++ b/src/components/lang/Translate.js @@ -0,0 +1,8 @@ +import en from './en.js'; +import es from './es.js'; +const languages = {en, es}; +const userLanguage = (navigator.language || navigator.userLanguage).substr(0,2); +export const Translate = ({word}) => translate(word); +export const translate = (word) => languages[userLanguage] ? + languages[userLanguage][word] + : languages['en'][word]; \ No newline at end of file diff --git a/src/components/lang/en.js b/src/components/lang/en.js new file mode 100644 index 0000000..0be137d --- /dev/null +++ b/src/components/lang/en.js @@ -0,0 +1,23 @@ +export default { + APP_NAME: 'Catalogue Music', + FIRST_TITLE : 'Access', + FIRST_PARAGRAPH : 'Log in with your social network of choice and start playing with zero cost from now and forever.', + SECOND_TITLE : 'Artists', + SECOND_PARAGRAPH : 'We are working to involve the artists and collaborate with them in reaching their audience. We believe in the possibility of a self-sustainable platform and in the commitment between users and musicians.', + THIRD_TITLE : 'Technology', + THIRD_PARAGRAPH : 'Our goal is to offer a premium quality service with minimum latency and cutting-edge technology.', + ARTISTS: 'Artists', + ALBUMS: 'Albums', + HOME: 'Home', + SEARCH: 'Search', + FAVORITES_SHORT: 'Favs', + PLAYER: 'Player', + EXIT: 'Exit', + PLAY: 'Play', + ALBUMS_INDEXED: 'album/s in Catalogue', + SEARCH_INPUT: 'Type to find music', + PLAYER_HISTORY: 'History', + PLAYER_NEXT: 'Next', + FAVORITES: 'Favorites', + TRACKS_FAVORITED: 'tracks favorited' +} \ No newline at end of file diff --git a/src/components/lang/es.js b/src/components/lang/es.js new file mode 100644 index 0000000..309a63b --- /dev/null +++ b/src/components/lang/es.js @@ -0,0 +1,23 @@ +export default { + APP_NAME: 'Catalogue Music', + FIRST_TITLE : 'Acceso', + FIRST_PARAGRAPH : 'Ingresá con tu red social preferida y escuchá sin límites ahora mismo y por siempre.', + SECOND_TITLE : 'Artistas', + SECOND_PARAGRAPH : 'Estamos trabajando para involucrar a los artistas y ayudarlos a llegar a su audiencia. Creemos en la posibilidad de una plataforma auto-sustentable y en el compromiso mutuo entre usuarios y artistas.', + THIRD_TITLE : 'Tecnología', + THIRD_PARAGRAPH : 'Nuestro objetivo es ofrecer un servicio de calidad, con latencia mínima y la última tecnología.', + ARTISTS: 'Artistas', + ALBUMS: 'Álbums', + HOME: 'Inicio', + SEARCH: 'Buscar', + FAVORITES_SHORT: 'Favs', + PLAYER: 'Player', + EXIT: 'Salir', + PLAY: 'Play', + ALBUMS_INDEXED: 'álbum/s en Catalogue', + SEARCH_INPUT: 'Escribe para buscar música', + PLAYER_HISTORY: 'Historial', + PLAYER_NEXT: 'Próximo', + FAVORITES: 'Favoritos', + TRACKS_FAVORITED: 'canciones en Favoritos' +} \ No newline at end of file