Skip to content

Commit 4e4f267

Browse files
committed
🌐 Add i18n support and update language settings
1 parent caec90e commit 4e4f267

18 files changed

+540
-179
lines changed

astro.config.mjs

+7
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ import svelte from '@astrojs/svelte';
55
// https://astro.build/config
66
export default defineConfig({
77
integrations: [svelte()],
8+
i18n: {
9+
defaultLocale: 'es',
10+
locales: ['es', 'en'],
11+
routing: {
12+
prefixDefaultLocale: false,
13+
},
14+
},
815
});

lint-staged.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default {
2-
'*.{js,jsx,ts,tsx,astro}': ['eslint --fix', 'eslint'],
2+
'*.{js,jsx,astro}': ['eslint --fix', 'eslint'],
33
'**/*.ts?(x)': () => 'npm run build-types',
44
};

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"build": "astro check && astro build",
99
"preview": "astro preview",
1010
"astro": "astro",
11-
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.astro . & npm run stylelint",
12-
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx,.astro . --fix & npm run stylelint:fix",
13-
"lint:watch": "eslint --ext .js,.jsx,.ts,.tsx,.astro . --watch",
11+
"lint": "eslint --ext .js,.jsx,.astro . & npm run stylelint",
12+
"lint:fix": "eslint --ext .js,.jsx,.astro . --fix & npm run stylelint:fix",
13+
"lint:watch": "eslint --ext .js,.jsx,.astro . --watch",
1414
"stylelint": "stylelint 'src/**/*.{css,scss,astro}'",
1515
"stylelint:fix": "stylelint 'src/**/*.{css,scss,astro}' --fix",
1616
"stylelint:watch": "stylelint 'src/**/*.{css,scss,astro}' --watch",

src/components/About.astro

+19-33
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
---
2-
const YEARS_OLD = new Date().getFullYear() - 2001;
2+
import { getI18n } from '@i18n/index';
3+
4+
const { currentLocale } = Astro;
5+
6+
const i18n = getI18n({ currentLocale });
37
---
48

59
<section id="about">
6-
<span class="title">About me 👨</span>
10+
<span class="title">{i18n.ABOUT_SECTION.TITLE} 👨</span>
711
<div class="wrap">
812
<div class="description">
9-
<p>
10-
My name is <span class="high">Marco Antonio Cruz Gabino</span>.
11-
I am {YEARS_OLD} years old and I am currently studying computer science.
12-
I am passionate about
13-
<span class="high">writing code, solving problems and creating software</span>.
14-
I am a responsible, self-taught, dynamic person with great capacity for teamwork.
15-
</p>
16-
<br>
17-
<p>
18-
Currently, I am expanding my skills into
19-
<span class="high">backend development</span> to complement
20-
my existing web development expertise
21-
</p>
13+
<p set:html={i18n.ABOUT_SECTION.DESCRIPTION_1}></p>
14+
<p set:html={i18n.ABOUT_SECTION.DESCRIPTION_2}></p>
15+
<p set:html={i18n.ABOUT_SECTION.DESCRIPTION_3}></p>
2216
</div>
2317
<div class="image">
24-
<figure>
25-
<img src="programming.webp" alt="programming-image">
26-
</figure>
18+
<img src="programming.webp" alt={i18n.ABOUT_SECTION.IMAGE.ALT}>
2719
</div>
2820
</div>
2921
</section>
@@ -45,30 +37,24 @@ const YEARS_OLD = new Date().getFullYear() - 2001;
4537

4638
.description {
4739
font-size: 22px;
48-
font-weight: 500;
40+
font-weight: normal;
4941
line-height: 1.5;
50-
color: var(--font-color-2);
42+
color: var(--font-color-1);
43+
text-wrap: pretty;
5144
}
5245

53-
.description .high {
54-
color: var(--primary-color);
46+
.description p {
47+
margin-bottom: 1rem;
5548
}
5649

5750
.image {
5851
flex: 1;
5952
}
6053

61-
section figure {
62-
display: inline-block;
63-
box-sizing: border-box;
64-
width: 20rem;
65-
height: 19rem;
66-
}
67-
68-
section figure img {
54+
section img {
6955
object-fit: cover;
70-
width: 100%;
71-
height: 100%;
56+
width: 22rem;
57+
height: 20rem;
7258
border-radius: 51% 49% 49% 51% / 49% 52% 48% 51%;
7359
border: 3px solid var(--primary-color);
7460
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.3);
@@ -91,7 +77,7 @@ const YEARS_OLD = new Date().getFullYear() - 2001;
9177
}
9278

9379
@media (max-width: 480px) {
94-
section figure {
80+
section img {
9581
width: 15rem;
9682
height: 14rem;
9783
}

src/components/App.astro

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
import About from '@components/About.astro';
3+
import ButtonTop from '@components/buttons/button-top.svelte';
4+
import Contact from '@components/Contact.astro';
5+
import Header from '@components/Header.astro';
6+
import Hero from '@components/Hero.astro';
7+
import Navigation from '@components/Navigation.svelte';
8+
import Portfolio from '@components/Portfolio.astro';
9+
import Skills from '@components/Skills.astro';
10+
import { getI18n } from '@i18n/index';
11+
import Layout from '@layouts/Layout.astro';
12+
13+
const { currentLocale } = Astro;
14+
15+
const i18n = getI18n({ currentLocale });
16+
---
17+
18+
<Layout title={i18n.SEO_TITLE} description={i18n.SEO_DESCRIPTION} language={i18n.LANGUAGE}>
19+
<div class="wrapper">
20+
<Header />
21+
<Navigation client:load/>
22+
<div class="content">
23+
<div class="blur bottom"></div>
24+
<div class="blur top"></div>
25+
<Hero />
26+
<About />
27+
<Skills />
28+
<Portfolio />
29+
<Contact />
30+
</div>
31+
</div>
32+
<ButtonTop client:idle/>
33+
</Layout>
34+
35+
<style>
36+
.wrapper {
37+
opacity: 1;
38+
visibility: visible;
39+
transition: opacity 2.2s ease-in-out, visibility 2.2s ease-in-out, height 2.2s ease-in-out;
40+
overflow: hidden;
41+
max-width: 1200px;
42+
min-width: 380px;
43+
height: auto;
44+
margin: 0 auto;
45+
position: relative;
46+
}
47+
48+
.content {
49+
margin: 0 1rem;
50+
}
51+
52+
.blur {
53+
position: fixed;
54+
width: 14rem;
55+
height: 14rem;
56+
border-radius: 50%;
57+
background: #60a5fa;
58+
z-index: -9;
59+
filter: blur(200px);
60+
}
61+
62+
.blur.bottom {
63+
top: 620px;
64+
left: 25%;
65+
}
66+
67+
.blur.top {
68+
top: 100px;
69+
left: 75%;
70+
}
71+
72+
@media (max-width: 900px) {
73+
.content {
74+
margin: 0 1rem;
75+
}
76+
}
77+
78+
@media (max-width: 480px) {
79+
.blur.bottom {
80+
top: 380px;
81+
left: 0%;
82+
}
83+
.blur.top {
84+
top: 90px;
85+
left: 40%;
86+
}
87+
}
88+
</style>

src/components/Contact.astro

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ import {
1212
LINKEDIN_URL,
1313
TWITTER_URL,
1414
} from '@constants/urls';
15+
import { getI18n } from '@i18n/index';
1516
17+
const { currentLocale } = Astro;
18+
19+
const i18n = getI18n({ currentLocale });
1620
---
1721

1822
<section id="contact">
19-
<span class="title">Contact me ✉️</span>
23+
<span class="title">{i18n.CONTACT_SECTION.TITLE} ✉️</span>
2024
<div class="container">
2125
<p class="description">
22-
I’m currently looking for new opportunities, my inbox is always open!
26+
{i18n.CONTACT_SECTION.DESCRIPTION}
2327
</p>
2428
<div class="email-wrapper">
2529
<div class="email">
@@ -52,7 +56,7 @@ import {
5256
</div>
5357
<div class="detail">
5458
<span class="text">
55-
Design and Built with ❤️ by
59+
{i18n.FOOTER.DESCRIPTION}
5660
<a target="_blank" href={GITHUB_URL} aria-label="Github profile">
5761
Marco Cruz
5862
</a>

src/components/Hero.astro

+27-21
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,32 @@
22
import GithubIcon from '@components/icons/github-icon.astro';
33
import LinkedinIcon from '@components/icons/linkedin-icon.astro';
44
import { GITHUB_URL, LINKEDIN_URL } from '@constants/urls.ts';
5+
import { getI18n } from '@i18n/index';
6+
7+
const { currentLocale } = Astro;
8+
9+
const i18n = getI18n({ currentLocale });
510
---
611

712
<section class="home" id="home">
813
<div class="main-title">
9-
<h1 class="title">Hello there!<span>✌️</span></h1>
10-
<h2 class="title">I'm <span class="subtitle-name">Marco Cruz</span></h2>
11-
<span class="title-job">Frontend Developer</span>
14+
<h1 class="title">{i18n.HERO_SECTION.TITLE}<span>✌️</span></h1>
15+
<h2 class="title">
16+
{i18n.HERO_SECTION.SUBTITLE_NORMAL}
17+
<span class="subtitle-name">
18+
{i18n.HERO_SECTION.SUBTITLE_EMPHASIS}
19+
</span>
20+
</h2>
21+
<span class="title-job">
22+
{i18n.HERO_SECTION.JOB_TITLE}
23+
</span>
1224
<div class="bottom">
1325
<a
1426
class="btn"
1527
href="pdf/cv.pdf"
1628
download="cv - marco cruz.pdf"
17-
aria-label="Download CV">
18-
Download CV
29+
aria-label={i18n.HERO_SECTION.CV.ARIA_LABEL}>
30+
{i18n.HERO_SECTION.CV.BTN_TEXT}
1931
</a>
2032
<div class="social">
2133
<a target="_blank" href={GITHUB_URL} class="icon" aria-label="Github">
@@ -27,9 +39,8 @@ import { GITHUB_URL, LINKEDIN_URL } from '@constants/urls.ts';
2739
</div>
2840
</div>
2941
</div>
30-
<figure>
31-
<img src="me.webp" alt="profile-image" class="profile">
32-
</figure>
42+
43+
<img src="me.webp" alt={i18n.HERO_SECTION.IMAGE.ALT} class="profile">
3344
</section>
3445

3546
<style>
@@ -126,32 +137,25 @@ import { GITHUB_URL, LINKEDIN_URL } from '@constants/urls.ts';
126137
color: var(--font-color-2);
127138
}
128139

129-
.home figure {
130-
display: inline-block;
131-
box-sizing: border-box;
132-
width: 30rem;
133-
height: 28rem;
134-
}
135-
136140
img {
137141
object-fit: cover;
138-
width: 100%;
139-
height: 100%;
142+
width: 30rem;
143+
height: 28rem;
140144
border-radius: 63% 37% 48% 52% / 60% 57% 43% 40%;
141145
border: 3px solid var(--primary-color);
142146
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.3);
143147
background: #3b82f6;
144148
}
145149

146150
@media (max-width: 1024px) {
147-
.home figure {
151+
img.profile {
148152
width: 28rem;
149153
height: 23rem;
150154
}
151155
}
152156

153157
@media (max-width: 900px) {
154-
.home figure {
158+
img.profile {
155159
width: 28rem;
156160
height: 23rem;
157161
}
@@ -174,7 +178,8 @@ import { GITHUB_URL, LINKEDIN_URL } from '@constants/urls.ts';
174178
span.title-job {
175179
font-size: 28px;
176180
}
177-
.home figure {
181+
182+
img.profile {
178183
width: 18rem;
179184
height: 18rem;
180185
}
@@ -191,7 +196,8 @@ import { GITHUB_URL, LINKEDIN_URL } from '@constants/urls.ts';
191196
span.title-job {
192197
font-size: 28px;
193198
}
194-
.home figure {
199+
200+
img.profile {
195201
width: 14rem;
196202
height: 14rem;
197203
}

0 commit comments

Comments
 (0)