From efd27110bd0c920843c214f2a7f8f6ac4b037810 Mon Sep 17 00:00:00 2001 From: Paul T Date: Mon, 15 Apr 2024 13:07:43 -0400 Subject: [PATCH] feat: add initial mult-lingaal support for template Using linguify to support multiple languages --- lang.toml | 30 ++++++++++++++++++++++++++++++ lib.typ | 28 +++++++++++++++++++++------- template/coverletter.typ | 1 + template/coverletter2.typ | 1 + template/resume.typ | 1 + 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 lang.toml diff --git a/lang.toml b/lang.toml new file mode 100644 index 0000000..072f444 --- /dev/null +++ b/lang.toml @@ -0,0 +1,30 @@ +[conf] +default-lang = "en" + +[lang.en] +resume = "Résumé" +dear = "Dear" +cover-letter = "Cover Letter" +attached = "Attached" +curriculum-vitae = "Curriculum Vitae" + +[lang.de] +resume = "Lebenslauf" +dear = "Sehr geehrte" +cover-letter = "Anschreiben" +attached = "Angehängt" +curriculum-vitae = "Lebenslauf" + +[lang.gr] +resume = "Βιογραφικό" +dear = "Αγαπητέ" +cover-letter = "Συνοδευτική Επιστολή" +attached = "Συνημμένο" +curriculum-vitae = "Βιογραφικό" + +[lang.sp] +resume = "Currículum" +dear = "Estimado" +cover-letter = "Carta de Presentación" +attached = "Adjunto" +curriculum-vitae = "Currículum" diff --git a/lib.typ b/lib.typ index 4c42644..932748d 100644 --- a/lib.typ +++ b/lib.typ @@ -1,4 +1,5 @@ #import "@preview/fontawesome:0.1.0": * +#import "@preview/linguify:0.4.0": * // const color #let color-darknight = rgb("#131A28") @@ -126,6 +127,7 @@ /// - date (string): The date the resume was created /// - accent-color (color): The accent color of the resume /// - colored-headers (boolean): Whether the headers should be colored or not +/// - language (string): The language of the resume, defaults to "en". See lang.toml for available languages /// - body (content): The body of the resume /// -> none #let resume( @@ -133,12 +135,15 @@ date: datetime.today().display("[month repr:long] [day], [year]"), accent-color: default-accent-color, colored-headers: true, + language: "en", body, ) = { if type(accent-color) == "string" { accent-color = rgb(accent-color) } + let lang_data = toml("lang.toml") + set document( author: author.firstname + " " + author.lastname, title: "resume", @@ -146,7 +151,7 @@ set text( font: ("Source Sans Pro"), - lang: "en", + lang: language, size: 11pt, fill: color-darkgray, fallback: true, @@ -167,7 +172,7 @@ #author.firstname #author.lastname #sym.dot.c - #"Résumé" + #linguify("resume", from: lang_data) ] ][ #counter(page).display() @@ -410,20 +415,24 @@ profile-picture: image, date: datetime.today().display("[month repr:long] [day], [year]"), accent-color: default-accent-color, + language: "en", body, ) = { if type(accent-color) == "string" { accent-color = rgb(accent-color) } + // language data + let lang_data = toml("lang.toml") + set document( author: author.firstname + " " + author.lastname, - title: "resume", + title: "cover-letter", ) set text( font: ("Source Sans Pro"), - lang: "en", + lang: language, size: 11pt, fill: color-darkgray, fallback: true, @@ -444,7 +453,7 @@ #author.firstname #author.lastname #sym.dot.c - #"Cover Letter" + #linguify("cover-letter", from: lang_data) ] ][ #counter(page).display() @@ -594,7 +603,10 @@ #pad(bottom: 2em)[ #text(weight: "light")[Sincerely,] \ #text(weight: "bold")[#author.firstname #author.lastname] \ \ - #text(weight: "light", style: "italic")[Attached: Curriculum Vitae] + #text(weight: "light", style: "italic")[ #linguify( + "attached", + from: lang_data, + )#sym.colon #linguify("curriculum-vitae", from: lang_data)] ] ] } @@ -635,13 +647,15 @@ /// - job-position (string): The job position you are applying for /// - addressee (string): The person you are addressing the letter to #let letter-heading(job-position: "", addressee: "") = { + let lang_data = toml("lang.toml") + // TODO: Make this adaptable to content underline(evade: false, stroke: 0.5pt, offset: 0.3em)[ #text(weight: "bold", size: 12pt)[Job Application for #job-position] ] pad(top: 1em, bottom: 1em)[ #text(weight: "light", fill: color-gray)[ - Dear #addressee, + #linguify("dear", from: lang_data) #addressee, ] ] } diff --git a/template/coverletter.typ b/template/coverletter.typ index f95d1c8..6896440 100644 --- a/template/coverletter.typ +++ b/template/coverletter.typ @@ -15,6 +15,7 @@ ), ), profile-picture: image("./profile.png"), + language: "en", ) #hiring-entity-info(entity-info: ( diff --git a/template/coverletter2.typ b/template/coverletter2.typ index ba4525f..803366e 100644 --- a/template/coverletter2.typ +++ b/template/coverletter2.typ @@ -15,6 +15,7 @@ ), ), profile-picture: none, + language: "en" ) #hiring-entity-info(entity-info: ( diff --git a/template/resume.typ b/template/resume.typ index f7a0af2..4204dda 100644 --- a/template/resume.typ +++ b/template/resume.typ @@ -16,6 +16,7 @@ ), ), date: datetime.today().display(), + language: "en", colored-headers: true, )