✨ 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');
|
||||
|
||||
/* V A R I A B L E S */
|
||||
|
@ -5,8 +5,7 @@
|
||||
// Print cards
|
||||
const printCards = () => {
|
||||
for (const card of CONFIG.cards) {
|
||||
console.log(card.id);
|
||||
|
||||
|
||||
// Card Item
|
||||
let item = `
|
||||
<a
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
const iconElement = document.querySelector('.weather-icon');
|
||||
const tempElement = document.querySelector('.temperature-value p');
|
||||
const descElement = document.querySelector(
|
||||
'.temperature-description p'
|
||||
);
|
||||
const descElement = document.querySelector('.temperature-description p');
|
||||
|
||||
// App data
|
||||
const weather = {};
|
||||
@ -33,17 +31,21 @@ function setPosition(position) {
|
||||
}
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => {
|
||||
getWeather(pos.coords.latitude.toFixed(3), pos.coords.longitude.toFixed(3));
|
||||
}, (err) => {
|
||||
getWeather(
|
||||
pos.coords.latitude.toFixed(3),
|
||||
pos.coords.longitude.toFixed(3)
|
||||
);
|
||||
},
|
||||
(err) => {
|
||||
console.error(err);
|
||||
getWeather(CONFIG.defaultLatitude, CONFIG.defaultLongitude);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Get the Weather data
|
||||
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);
|
||||
|
||||
|
@ -23,10 +23,12 @@ const CONFIG = {
|
||||
greetingNight: 'Go to Sleep!',
|
||||
|
||||
// Weather
|
||||
weatherKey: 'InsertYourAPIKeyHere123456',
|
||||
weatherKey: '15fe26a8e22e4783054e3273824c5e7b',
|
||||
weatherIcons: 'OneDark', // 'Nord', 'Dark', 'White'
|
||||
weatherUnit: 'C',
|
||||
trackLocation: false, // If false or an error occurs, the app will use the lat/lon below
|
||||
weatherUnit: 'C', // 'F', 'C'
|
||||
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',
|
||||
defaultLongitude: '-122.419',
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user