Skip to content

Commit 66dfaae

Browse files
committed
🌐 Update Navigation component with localized text
1 parent 4e4f267 commit 66dfaae

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

src/components/Navigation.svelte

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,31 @@
88
import MoonIcon from '@components/icons/moon-icon.svelte';
99
import { onMount } from 'svelte';
1010
11+
import { getI18n } from '@i18n/index';
12+
1113
let current = '';
1214
let scrollY = 0;
1315
let darkThemeName = 'dark-theme'; // nombre de la clase para el tema oscuro
1416
let isDarkTheme = false; // indicador del estado del tema
17+
let home, about, skills, portfolio, contact;
18+
let theme = {
19+
dark: 'dark-theme',
20+
light: 'light-theme',
21+
};
1522
1623
onMount(() => {
1724
isDarkTheme = document.body.classList.contains(darkThemeName);
25+
let language = document.documentElement.lang;
26+
const i18n = getI18n({ currentLocale: language });
27+
home = i18n.HERO_SECTION.TITLE_NAV;
28+
about = i18n.ABOUT_SECTION.TITLE;
29+
skills = i18n.SKILLS_SECTION.TITLE;
30+
portfolio = i18n.PORTFOLIO_SECTION.TITLE;
31+
contact = i18n.CONTACT_SECTION.TITLE;
32+
theme = {
33+
dark: i18n.THEME.DARK_THEME,
34+
light: i18n.THEME.LIGHT_THEME,
35+
};
1836
window.addEventListener('scroll', handleScroll);
1937
return () => {
2038
window.removeEventListener('scroll', handleScroll);
@@ -54,31 +72,31 @@
5472
<li class="home active">
5573
<a href="#home" aria-label="Home section">
5674
<HomeIcon />
57-
<span class="title">Home</span>
75+
<span class="title"> {home} </span>
5876
</a>
5977
</li>
6078
<li class="about">
6179
<a href="#about" aria-label="About section">
6280
<UserIcon />
63-
<span class="title">About me</span>
81+
<span class="title">{about}</span>
6482
</a>
6583
</li>
6684
<li class="skills">
6785
<a href="#skills" aria-label="Skills section">
6886
<WrenchIcon />
69-
<span class="title">My skills</span>
87+
<span class="title">{skills}</span>
7088
</a>
7189
</li>
7290
<li class="portfolio">
7391
<a href="#portfolio" aria-label="Portfolio section">
7492
<BriefcaseIcon />
75-
<span class="title">My portfolio</span>
93+
<span class="title">{portfolio}</span>
7694
</a>
7795
</li>
7896
<li class="contact">
7997
<a href="#contact" aria-label="Contact section">
8098
<EnvelopeIcon />
81-
<span class="title">Contact me</span>
99+
<span class="title">{contact}</span>
82100
</a>
83101
</li>
84102
<li class="divisor">
@@ -89,10 +107,10 @@
89107
<a on:click={setTheme} aria-label="Change theme">
90108
{#if isDarkTheme}
91109
<SunIcon />
92-
<span class="title">Light theme</span>
110+
<span class="title">{theme.light}</span>
93111
{:else}
94112
<MoonIcon />
95-
<span class="title">Dark theme</span>
113+
<span class="title">{theme.dark}</span>
96114
{/if}
97115
</a>
98116
</li>
@@ -112,10 +130,6 @@
112130
transform: translate(-50%, -50%);
113131
}
114132
115-
nav ul.nav li a fa-icon {
116-
font-size: 12px;
117-
}
118-
119133
nav ul.nav {
120134
padding: 0.6rem;
121135
display: flex;

src/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"SEO_DESCRIPTION": "Explore my portfolio to see my projects and skills. I'm a full-stack developer and I love to create websites and apps.",
55
"HERO_SECTION": {
66
"TITLE": "Hello there!",
7+
"TITLE_NAV": "Home",
78
"SUBTITLE_NORMAL": "I'm",
89
"SUBTITLE_EMPHASIS": "Marco Cruz",
910
"JOB_TITLE": "Frontend Developer",
@@ -154,5 +155,9 @@
154155
},
155156
"FOOTER": {
156157
"DESCRIPTION": "Designed and Built with ❤️ by"
158+
},
159+
"THEME": {
160+
"DARK_THEME": "Dark theme",
161+
"LIGHT_THEME": "Light theme"
157162
}
158163
}

src/i18n/es.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"SEO_DESCRIPTION": "Explora mi portafolio para ver mis proyectos y habilidades. Soy un desarrollador full-stack y me encanta crear sitios web y aplicaciones.",
55
"HERO_SECTION": {
66
"TITLE": "¡Hola!",
7+
"TITLE_NAV": "Inicio",
78
"SUBTITLE_NORMAL": "Soy",
89
"SUBTITLE_EMPHASIS": "Marco Cruz",
910
"JOB_TITLE": "Desarrollador Frontend",
@@ -154,5 +155,9 @@
154155
},
155156
"FOOTER": {
156157
"DESCRIPTION": "Diseñado y Construido con ❤️ por"
158+
},
159+
"THEME": {
160+
"DARK_THEME": "Tema oscuro",
161+
"LIGHT_THEME": "Tema claro"
157162
}
158163
}

0 commit comments

Comments
 (0)