Skip to content

Commit

Permalink
i18n support added
Browse files Browse the repository at this point in the history
- added i18n support
- made bibliography file configurable
- minor changes (removed unused stuff and fixed warnings)
  • Loading branch information
daddinuz committed Nov 1, 2024
1 parent fcd335d commit 2df51ae
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 34 deletions.
30 changes: 30 additions & 0 deletions i18n.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#let i18n = (
en: (
draft_dated: "Draft dated",
department_of: "Department of",
degree_course_in: "Degree programme class in",
supervisor: "Supervisor",
assistant_supervisor: "Assistant supervisor",
assistant_supervisors: "Assistant supervisors",
presented_by: "Presented by",
graduation_session_of: "Graduation session of",
academic_year: "Academic year",
abstract: "Abstract",
table_of_contents: "Table of contents",
bibliography: "Bibliography",
),
it: (
draft_dated: "Bozza del",
department_of: "Dipartimento di",
degree_course_in: "Corso di",
supervisor: "Relatore",
assistant_supervisor: "Correlatore",
assistant_supervisors: "Correlatori",
presented_by: "Presentata da",
graduation_session_of: "Sessione di",
academic_year: "Anno accademico",
abstract: "Sommario",
table_of_contents: "Indice dei contenuti",
bibliography: "Bibliografia",
),
)
49 changes: 24 additions & 25 deletions template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
#import "@preview/fletcher:0.4.2" as fletcher: node, edge
#import "@preview/wrap-it:0.1.0": wrap-content
#import "@preview/lovelace:0.2.0": *

#let algorithm = algorithm.with(supplement: "Algoritmo")

#import "i18n.typ": *

#let project(
title: [],
subtitle: [],
author: [],
professors: (),
school: [],
department: [],
course: [],
session: [],
aa: [],
academic_year: [],
abstract: [],
dedication: [],
final: false,
locale: "it",
bibliography_file: "./bibliography.bib",
body,
) = {
set document(author: author, title: title)

set page(
paper: "a4",
margin: (x: 2.5cm, y: 1.25cm),
Expand All @@ -33,21 +33,20 @@

set text(
font: "Libertinus Serif",
lang: "it",
region: "it",
lang: locale,
region: locale,
size: 12pt,
hyphenate: true,
)

// Bozza header
set page(header: if not final {
box(
width: 100%,
stroke: 1pt + red,
inset: .5em,
align(
center + horizon,
text(fill: red, size: 18pt, [Bozza del #datetime.today().display("[day]/[month]/[year]")]),
text(fill: red, size: 18pt, [#i18n.at(locale).draft_dated #datetime.today().display("[day]/[month]/[year]")]),
),
)
} else {
Expand All @@ -58,14 +57,13 @@
align(
center,
[
#image(logo, width: 6.5cm)
#v(2em, weak: true)
#upper[Dipartimento di #text(department)]
#upper[#i18n.at(locale).department_of #text(department)]
#v(2em, weak: true)
#text(size: 14pt, strong([Corso di #text(course)]))
#text(size: 14pt, strong([#i18n.at(locale).degree_course_in #text(course)]))
#line(stroke: (dash: "dotted", thickness: 1pt), length: 100%)
#v(5em)
Expand All @@ -81,20 +79,20 @@
rows: 1,
row-gutter: 2em,
[
*Relatore:* \
*#text(i18n.at(locale).supervisor):* \
#text(professors.at(0), hyphenate: false)
],
{ },
[
*Presentata da:* \
*#text(i18n.at(locale).presented_by):* \
#text(author)
],
{
if professors.len() > 1 {
let title = if professors.len() == 2 {
"Correlatore:"
i18n.at(locale).assistant_supervisor
} else {
"Correlatori:"
i18n.at(locale).assistant_supervisors
}
text(size: 14pt, weight: "bold", title)
linebreak()
Expand All @@ -110,8 +108,8 @@
#line(stroke: (dash: "solid", thickness: 1pt), length: 100%)
Sessione #text(session) \
Anno accademico #text(aa)
#i18n.at(locale).graduation_session_of #text(session) \
#i18n.at(locale).academic_year #text(academic_year)
]
]
],
Expand All @@ -134,14 +132,14 @@
counter(page).update(1) // reset page counter
show par: set block(spacing: 1.6em)
set par(spacing: 1.6em)
show heading: set block(spacing: 1em)
if abstract != [] {
align(
horizon,
{
heading(level: 1, "Sommario")
heading(level: 1, i18n.at(locale).abstract)
text(abstract)
},
)
Expand All @@ -155,14 +153,13 @@
set page(numbering: "1")
outline(title: [ Indice dei contenuti ], indent: 20pt, depth: 2)
outline(title: i18n.at(locale).table_of_contents, indent: 20pt, depth: 2)
{
show heading.where(level: 1): it => {
pagebreak()
v(8cm)
set par(justify: false)
show par: set block(spacing: 0cm)
set par(justify: false, spacing: 0cm)
let c = counter(heading).display("1")
// text(size: 40pt, c)
v(1cm)
Expand All @@ -186,6 +183,7 @@
set-page-properties()
show: codly-init.with()
codly(
number-format: none,
zebra-fill: none,
Expand All @@ -199,9 +197,10 @@
body
bibliography(
"./bibliography.bib",
bibliography_file,
title: i18n.at(locale).bibliography,
style: "institute-of-electrical-and-electronics-engineers",
// style: "association-for-computing-machinery",
style: "institute-of-electrical-and-electronics-engineers"
)
}
}
14 changes: 5 additions & 9 deletions tesi.typ
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
"Prof. Gatto Silvestro",
"Dott. Paperino"
),
department: "Dipartimento della Televisione dei Ragazzi",
department: "Televisione dei Ragazzi",
course: "Laurea in Scienze dell'Albero Azzurro",
session: "di Luglio",
aa: "2000/2001",
session: "Luglio",
academic_year: "2000/2001",
abstract: [
#lorem(100)
],
dedication: [
A quella puntata della Melevisione interrotta a metà.
],
final: true,
// locale: "en",
// bibliography_file: "./bib.yml",
)

= Introduzione
Expand All @@ -41,9 +43,3 @@ if x == 1 {
print("Hello, world!")
}
```






0 comments on commit 2df51ae

Please sign in to comment.