Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n support added #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]")]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a field for date display in i18n.typ

Copy link
Contributor Author

@daddinuz daddinuz Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll add an entry to specify the date format string. Do you have any specific format in mind for the en locale? en-uk should be the same of it locale, but en-us would have month and day swapped, but I wouldn't go this deeper though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the US format, but I don't think we need it right now so no problems

),
)
} 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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to make this completely customizable, as someone could want to use "Computer Science Department" instead of "Department of Computer Science"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, totally agree. I'll make it an argument of the project.

#v(2em, weak: true)

#text(size: 14pt, strong([Corso di #text(course)]))
#text(size: 14pt, strong([#i18n.at(locale).degree_course_in #text(course)]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as before, "Computer Engineering Degree" instead of "Degree programme class in"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this

#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!")
}
```