SPB Git

Repository Public

Templates+Correspondence.swift 13.6 KB 167 lines swift

1// ORIX Docs2// File: Packages/ORIXDocsKit/Sources/DocTemplates/Templates+Correspondence.swift3// Description: Business letter, cover letter and résumé templates.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8import DocModel910extension TemplateLibrary {11    /// Styles shared by the two letters. Everything is based on Normal so a theme change carries over.12    private static func letterStyles(_ b: inout TemplateBuilder) {13        let t = b.t14        b.adjust(StyleID.normal) { $0.para.spaceAfter = 10; $0.para.lineSpacing = .multiple(1.2) }15        b.define("DateLine", t("Date Line", "Date"), next: "Recipient", para: ParaProps(spaceBefore: 6, spaceAfter: 20))16        b.define("Recipient", t("Recipient", "Vedette"), next: "Recipient", para: ParaProps(spaceAfter: 0, lineSpacing: .multiple(1.15), keepWithNext: true))17        b.define("Subject", t("Subject Line", "Objet"), next: "Salutation", char: CharProps(bold: true), para: ParaProps(spaceBefore: 18, spaceAfter: 12, keepWithNext: true))18        b.define("Salutation", t("Salutation", "Appel"), next: StyleID.normal, para: ParaProps(spaceBefore: 0, spaceAfter: 10, keepWithNext: true))19        b.define("Closing", t("Closing", "Salutation finale"), next: "Signature", para: ParaProps(spaceBefore: 6, spaceAfter: 40, keepWithNext: true))20        b.define("Signature", t("Signature", "Signature"), next: "Signature", para: ParaProps(spaceAfter: 0, lineSpacing: .multiple(1.15), keepLinesTogether: true))21        b.define("Enclosure", t("Enclosure", "Pièces jointes"), next: "Enclosure", char: CharProps(fontSize: b.theme.bodySize - 1.5, color: b.muted),22                 para: ParaProps(spaceBefore: 0, spaceAfter: 2))23    }2425    private static func recipientBlock(_ b: inout TemplateBuilder, _ lines: [String]) {26        for l in lines { b.p("Recipient", l) }27    }2829    // MARK: Business letter3031    static func businessLetter(_ c: TemplateContext) -> DocumentModel {32        var b = TemplateBuilder(c, theme: .classic, margins: Insets(top: 64, left: 80, bottom: 72, right: 80))33        let t = b.t34        letterStyles(&b)35        b.define("Letterhead", t("Letterhead", "En-tête de lettre"), next: "LetterheadDetails",36                 char: CharProps(fontFamily: b.theme.headingFont, fontSize: 18, bold: true, color: b.theme.accent, tracking: 0.4),37                 para: ParaProps(spaceAfter: 2, lineSpacing: .multiple(1.05), keepWithNext: true))38        b.define("LetterheadDetails", t("Letterhead Details", "Coordonnées de l'en-tête"), next: "DateLine",39                 char: CharProps(fontSize: b.theme.bodySize - 2.5, color: b.muted),40                 para: ParaProps(spaceAfter: 26, lineSpacing: .multiple(1.1), borderBottom: b.accentRule))4142        // First page: the letterhead is the header. Following pages: recipient and page number.43        b.setup.differentFirstPage = true44        b.setup.header = HeaderFooter(default: [b.header([r(t("[Recipient name]", "[Nom du destinataire]")), tab, r(b.dateText), tab, r("Page" + nbsp), field(.pageNumber)])])4546        b.p("Letterhead", b.organization)47        b.p("LetterheadDetails", t("[Street address] · [City, Province] [Postal code] · [Telephone] · [E-mail] · [Website]",48                                    "[Adresse municipale] · [Ville (Province)] [Code postal] · [Téléphone] · [Courriel] · [Site Web]"))49        b.p("DateLine", t.french ? t("", "[Ville], le ") + b.dateText : b.dateText)50        recipientBlock(&b, [t("[Recipient name]", "[Nom du destinataire]"), t("[Title]", "[Titre ou fonction]"), t("[Organization]", "[Organisation]"),51                            t("[Street address]", "[Adresse municipale]"), t("[City, Province] [Postal code]", "[Ville (Province)] [Code postal]")])52        b.p("Subject", t("Subject: [Subject of the letter]", "Objet : [Objet de la lettre]"))53        b.p("Salutation", t("Dear [Mr./Ms. Last name]:", "Madame, Monsieur,"))54        b.body(t("[State the purpose of the letter in the first sentence.] The opening paragraph tells the reader why you are writing and what you expect from them, in two or three sentences.",55                 "[Énoncez l'objet de la lettre dès la première phrase.] Le premier paragraphe indique au lecteur pourquoi vous lui écrivez et ce que vous attendez de lui, en deux ou trois phrases."))56        b.body(t("[Develop the facts, the context or the offer.] Keep one idea per paragraph, give dates, amounts and reference numbers precisely, and mention any enclosed document.",57                 "[Exposez les faits, le contexte ou l'offre.] Limitez-vous à une idée par paragraphe, donnez les dates, les montants et les numéros de référence avec précision, et signalez tout document joint."))58        b.body(t("[Close with the next step.] Say what will happen next, by when, and how the reader can reach you.",59                 "[Terminez par la suite à donner.] Précisez la prochaine étape, l'échéance et la façon de vous joindre."))60        b.p("Closing", t("Sincerely,", "Veuillez agréer, Madame, Monsieur, l'expression de mes sentiments distingués."))61        b.p("Signature", [b.authorRun])62        b.p("Signature", t("[Title]", "[Titre ou fonction]"))63        b.p("Signature", t("[Direct line] · [E-mail]", "[Ligne directe] · [Courriel]"))64        b.p("Enclosure", [r(t("Encl. ", "p. j. ")), r(t("[List of enclosed documents]", "[Liste des documents joints]"))], props: ParaProps(spaceBefore: 22))65        b.p("Enclosure", [r(t("cc: ", "c. c. ")), r(t("[Names of people receiving a copy]", "[Noms des personnes recevant une copie]"))])66        return b.build(title: t("[Subject of the letter]", "[Objet de la lettre]"))67    }6869    // MARK: Cover letter7071    static func coverLetter(_ c: TemplateContext) -> DocumentModel {72        var b = TemplateBuilder(c, theme: .modern, margins: Insets(top: 64, left: 76, bottom: 64, right: 76))73        let t = b.t74        letterStyles(&b)75        identityStyles(&b)76        b.p("ApplicantName", [b.authorRun])77        b.p("ContactLine", t("[City, Province] · [Telephone] · [E-mail] · [Portfolio or professional profile]",78                              "[Ville (Province)] · [Téléphone] · [Courriel] · [Portfolio ou profil professionnel]"))79        b.p("DateLine", t.french ? t("", "[Ville], le ") + b.dateText : b.dateText)80        recipientBlock(&b, [t("[Hiring manager's name]", "[Nom de la personne responsable du recrutement]"), t("[Title]", "[Titre ou fonction]"),81                            b.organization, t("[Street address]", "[Adresse municipale]"), t("[City, Province] [Postal code]", "[Ville (Province)] [Code postal]")])82        b.p("Subject", t("Re: Application for the position of [Position title] ([Reference number])",83                          "Objet : Candidature au poste de [Titre du poste] ([Numéro de référence])"))84        b.p("Salutation", t("Dear [Mr./Ms. Last name]:", "Madame, Monsieur,"))85        b.body(t("[Name the position and where you saw it, then say in one sentence why you are a strong match.] A specific opening shows that the letter was written for this employer.",86                 "[Nommez le poste et l'endroit où vous l'avez vu, puis dites en une phrase pourquoi votre profil y correspond.] Une entrée en matière précise montre que la lettre a été écrite pour cet employeur."))87        b.body(t("[Link your experience to the two or three requirements that matter most in the posting.] For example:",88                 "[Reliez votre expérience aux deux ou trois exigences les plus importantes de l'offre.] Par exemple :"))89        b.bullets([t("[Achievement with a measurable result that answers the first requirement]", "[Réalisation au résultat mesurable qui répond à la première exigence]"),90                   t("[Achievement that answers the second requirement]", "[Réalisation qui répond à la deuxième exigence]"),91                   t("[Skill or credential the posting asks for]", "[Compétence ou titre demandé dans l'offre]")])92        b.body(t("[Say what draws you to this organization: a project, a value, a challenge.] Two sentences are enough; avoid repeating your résumé.",93                 "[Dites ce qui vous attire dans cette organisation : un projet, une valeur, un défi.] Deux phrases suffisent ; évitez de répéter votre curriculum vitæ."))94        b.body(t("[Close by proposing a conversation and giving your availability.] Thank the reader for their time.",95                 "[Terminez en proposant une rencontre et en indiquant vos disponibilités.] Remerciez le lecteur de son attention."))96        b.p("Closing", t("Sincerely,", "Je vous prie d'agréer, Madame, Monsieur, mes salutations distinguées."))97        b.p("Signature", [b.authorRun])98        b.p("Enclosure", t("Encl. Résumé", "p. j. Curriculum vitæ"))99        return b.build(title: t("Cover letter – [Position title]", "Lettre de présentation – [Titre du poste]"))100    }101102    /// Name and contact line shared by the cover letter and the résumé, so the two documents match.103    private static func identityStyles(_ b: inout TemplateBuilder) {104        let t = b.t105        b.define("ApplicantName", t("Applicant Name", "Nom du candidat"), basedOn: StyleID.title, next: "ContactLine",106                 char: CharProps(fontSize: 26, color: b.theme.accent), para: ParaProps(spaceAfter: 2))107        b.define("ContactLine", t("Contact Line", "Coordonnées"), next: StyleID.normal, char: CharProps(fontSize: b.theme.bodySize - 1.5, color: b.muted),108                 para: ParaProps(spaceAfter: 18, lineSpacing: .multiple(1.1), borderBottom: b.accentRule))109    }110111    // MARK: Résumé112113    static func resume(_ c: TemplateContext) -> DocumentModel {114        var b = TemplateBuilder(c, theme: .modern, margins: Insets(top: 56, left: 60, bottom: 56, right: 60))115        let t = b.t116        let w = b.width117        let hair = b.hair118        identityStyles(&b)119        b.adjust(StyleID.normal) { $0.para.spaceAfter = 6; $0.para.lineSpacing = .multiple(1.18) }120        b.adjust(StyleID.heading(1)) {121            $0.char.fontSize = 12; $0.char.tracking = 1.2; $0.char.allCaps = true122            $0.para.spaceBefore = 16; $0.para.spaceAfter = 6; $0.para.borderBottom = hair123        }124        b.define("EntryTitle", t("Entry Title", "Titre d'entrée"), next: "EntryDetail", char: CharProps(bold: true),125                 para: ParaProps(spaceBefore: 6, spaceAfter: 0, keepWithNext: true, tabs: [TabStop(position: w, kind: .right)]))126        b.define("EntryDetail", t("Entry Detail", "Détail d'entrée"), next: StyleID.listParagraph, char: CharProps(italic: true, color: b.muted),127                 para: ParaProps(spaceAfter: 3, keepWithNext: true, tabs: [TabStop(position: w, kind: .right)]))128        b.define("SkillLine", t("Skill Line", "Ligne de compétences"), next: "SkillLine",129                 para: ParaProps(indentLeft: 130, firstLineIndent: -130, spaceAfter: 3, tabs: [TabStop(position: 130)]))130131        b.setup.differentFirstPage = true132        b.setup.footer = HeaderFooter(default: [b.footer([b.authorRun, tab, tab] + b.pageOfTotal)])133134        b.p("ApplicantName", [b.authorRun])135        b.p("ContactLine", t("[City, Province] · [Telephone] · [E-mail] · [Portfolio or professional profile]",136                              "[Ville (Province)] · [Téléphone] · [Courriel] · [Portfolio ou profil professionnel]"))137138        b.heading(1, t("Profile", "Profil"))139        b.body(t("[Three lines: your field, your years of experience, the strengths that set you apart and the kind of position you are looking for.]",140                 "[Trois lignes : votre domaine, vos années d'expérience, les forces qui vous distinguent et le type de poste recherché.]"))141142        b.heading(1, t("Experience", "Expérience professionnelle"))143        for n in 1...2 {144            b.p("EntryTitle", [r(t("[Job title \(n)]", "[Titre du poste \(n)]")), tab, r(t("[Month Year] – [Month Year]", "[Mois année] – [Mois année]"))])145            b.p("EntryDetail", [r(t("[Employer]", "[Employeur]")), tab, r(t("[City, Province]", "[Ville (Province)]"))])146            b.bullets([t("[Start with an action verb and end with a measurable result.]", "[Commencez par un verbe d'action et terminez par un résultat mesurable.]"),147                       t("[Describe a project you led: scope, team, outcome.]", "[Décrivez un projet que vous avez dirigé : portée, équipe, résultat.]"),148                       t("[Name the tools or methods the posting asks for.]", "[Nommez les outils ou les méthodes demandés dans l'offre.]")])149        }150151        b.heading(1, t("Education", "Formation"))152        b.p("EntryTitle", [r(t("[Degree, field of study]", "[Diplôme, domaine d'études]")), tab, r(t("[Year]", "[Année]"))])153        b.p("EntryDetail", [r(t("[Institution]", "[Établissement]")), tab, r(t("[City, Province]", "[Ville (Province)]"))])154        b.p("EntryTitle", [r(t("[Certificate or other degree]", "[Certificat ou autre diplôme]")), tab, r(t("[Year]", "[Année]"))])155        b.p("EntryDetail", [r(t("[Institution]", "[Établissement]")), tab, r(t("[City, Province]", "[Ville (Province)]"))])156157        b.heading(1, t("Skills", "Compétences"))158        b.p("SkillLine", [strong(t("Languages", "Langues")), tab, r(t("[Language (level)], [Language (level)]", "[Langue (niveau)], [Langue (niveau)]"))])159        b.p("SkillLine", [strong(t("Software", "Logiciels")), tab, r(t("[Tools you use with ease, most relevant first]", "[Outils que vous maîtrisez, les plus pertinents d'abord]"))])160        b.p("SkillLine", [strong(t("Certifications", "Certifications")), tab, r(t("[Professional designation, year]", "[Titre professionnel, année]"))])161162        b.heading(1, t("Community Involvement", "Engagement communautaire"))163        b.bullets([t("[Role, organization, years]", "[Rôle, organisme, années]")])164        return b.build(title: t("Résumé", "Curriculum vitæ"))165    }166}167
Files main
Menu

Theme