✨ Multi-language support
This commit is contained in:
parent
db91bd94b5
commit
065274074b
6
app.css
6
app.css
@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
// ╔╗ ╔═╗╔╗╔╔╦╗╔═╗
|
||||||
|
// ╠╩╗║╣ ║║║ ║ ║ ║
|
||||||
|
// ╚═╝╚═╝╝╚╝ ╩ ╚═╝
|
||||||
|
*/
|
||||||
|
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;700&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;700&display=swap');
|
||||||
|
|
||||||
/* V A R I A B L E S */
|
/* V A R I A B L E S */
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
// Print cards
|
// Print cards
|
||||||
const printCards = () => {
|
const printCards = () => {
|
||||||
for (const card of CONFIG.cards) {
|
for (const card of CONFIG.cards) {
|
||||||
console.log(card.id);
|
|
||||||
|
|
||||||
// Card Item
|
// Card Item
|
||||||
let item = `
|
let item = `
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
const iconElement = document.querySelector('.weather-icon');
|
const iconElement = document.querySelector('.weather-icon');
|
||||||
const tempElement = document.querySelector('.temperature-value p');
|
const tempElement = document.querySelector('.temperature-value p');
|
||||||
const descElement = document.querySelector(
|
const descElement = document.querySelector('.temperature-description p');
|
||||||
'.temperature-description p'
|
|
||||||
);
|
|
||||||
|
|
||||||
// App data
|
// App data
|
||||||
const weather = {};
|
const weather = {};
|
||||||
@ -33,17 +31,21 @@ function setPosition(position) {
|
|||||||
}
|
}
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
(pos) => {
|
(pos) => {
|
||||||
getWeather(pos.coords.latitude.toFixed(3), pos.coords.longitude.toFixed(3));
|
getWeather(
|
||||||
}, (err) => {
|
pos.coords.latitude.toFixed(3),
|
||||||
|
pos.coords.longitude.toFixed(3)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
getWeather(CONFIG.defaultLatitude, CONFIG.defaultLongitude);
|
getWeather(CONFIG.defaultLatitude, CONFIG.defaultLongitude);
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Weather data
|
// Get the Weather data
|
||||||
function getWeather(latitude, longitude) {
|
function getWeather(latitude, longitude) {
|
||||||
let api = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${key}`;
|
let api = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&lang=${CONFIG.language}&appid=${key}`;
|
||||||
|
|
||||||
console.log(api);
|
console.log(api);
|
||||||
|
|
||||||
|
@ -23,10 +23,12 @@ const CONFIG = {
|
|||||||
greetingNight: 'Go to Sleep!',
|
greetingNight: 'Go to Sleep!',
|
||||||
|
|
||||||
// Weather
|
// Weather
|
||||||
weatherKey: 'InsertYourAPIKeyHere123456',
|
weatherKey: '15fe26a8e22e4783054e3273824c5e7b',
|
||||||
weatherIcons: 'OneDark', // 'Nord', 'Dark', 'White'
|
weatherIcons: 'OneDark', // 'Nord', 'Dark', 'White'
|
||||||
weatherUnit: 'C',
|
weatherUnit: 'C', // 'F', 'C'
|
||||||
trackLocation: false, // If false or an error occurs, the app will use the lat/lon below
|
language: 'en', // More languages in https://openweathermap.org/current#multi
|
||||||
|
|
||||||
|
trackLocation: true, // If false or an error occurs, the app will use the lat/lon below:
|
||||||
defaultLatitude: '37.775',
|
defaultLatitude: '37.775',
|
||||||
defaultLongitude: '-122.419',
|
defaultLongitude: '-122.419',
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user