diff --git a/src/plugins/pdfMake.js b/src/plugins/pdfMake.js index bab1e6a..196c9bd 100644 --- a/src/plugins/pdfMake.js +++ b/src/plugins/pdfMake.js @@ -6,11 +6,71 @@ import { COLORS, WEEK_TYPES } from '@/constants' pdfMake.vfs = pdfFonts.pdfMake.vfs -const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] +const EN_MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] +const TPO_MONTHS = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'] +const SCHEDULE_TRANSLATIONS = { + en: { + startTime: '7:00', + group: 'CANTON CONGREGATION', + header: 'Our Christian Life & Ministry Schedule', + week: 'WEEK', + weeks: 'WEEKS', + months: EN_MONTHS, + weeklyBibleReading: 'WEEKLY BIBLE READING', + assemblyWeek: 'Assembly Week', + memorialWeek: 'Memorial Week', + noMeeting: 'No Meeting', + timeOff: 'Time Off', + prayer: 'Prayer', + openingComments: 'Opening Comments', + chairman: 'Chairman', + treasures: 'TREASURES FROM GOD\'S WORD', + bibleReading: 'Bible Reading', + gems: 'Digging for Spiritual Gems', + ministry: 'APPLY YOURSELF TO THE FIELD MINISTRY', + student: 'Student', + assistant: 'Assistant', + living: 'LIVING AS CHRISTIANS', + review: 'Review/Preview/Announcements', + co: 'Circuit Overseer', + cbs: 'Congregation Bible Study', + conductor: 'Conductor', + reader: 'Reader' + }, + tpo: { + startTime: '19:00', + group: 'GROUP PORTUGUÊS', + header: 'Programação de reunião de semana', + week: 'SEMANA', + weeks: 'SEMANAS', + months: TPO_MONTHS, + weeklyBibleReading: 'LEITURA SEMANAL DA BÍBLIA', + assemblyWeek: 'Semana da Assembleía', + memorialWeek: 'Semana da Comemoração', + noMeeting: 'Não Reunião', + timeOff: 'Fim', + prayer: 'Oração', + openingComments: 'Comentários iniciais', + chairman: 'Presidente', + treasures: 'TESOUROS DA PALAVRA DE DEUS', + bibleReading: 'Leitura da Bíblia', + gems: 'Em busca de pérolas espirituais', + ministry: 'EMPENHE-SE NO MINISTÉRIO', + student: 'Estudante', + assistant: 'Ajudante', + living: 'VIVER COMO CRISTÃOS', + review: 'Recapitulação/Antevisão/Anúncios', + co: 'Superintendente do Circuito', + cbs: 'Estudo Bíblico de Congregagação', + conductor: 'Dirigente', + reader: 'Leitor' + } +} const ASSIGNMENT_SLIP_TRANSLATIONS = { en: { verticalPadding: 32, defaultRoom: 'mainHall', + months: EN_MONTHS, title: 'OUR CHRISTIAN LIFE AND MINISTRY MEETING ASSIGNMENT', name: 'Name', assistant: 'Assistant', @@ -44,6 +104,7 @@ const ASSIGNMENT_SLIP_TRANSLATIONS = { tpo: { verticalPadding: 28, defaultRoom: 'class1', + months: TPO_MONTHS, title: 'DESIGNAÇÃO PARA A REUNIÃO VIDA E MINISTÉRIO CRISTÃOS', name: 'Nome', assistant: 'Ajudante', @@ -168,7 +229,13 @@ function createScheduleTable (markerColor, rows, expandAssigneeName) { margin: [0, 2, 0, 8], layout: { defaultBorder: false, - fillColor: (rowIndex, node, columnIndex) => rowIndex % 2 === 1 && columnIndex > 1 ? '#DEDEDE' : null, + fillColor: (rowIndex, node, columnIndex) => { + if (columnIndex > 1) { + if (rows[rowIndex][5]) return '#E3F2FD' // inherited flag + if (rowIndex % 2 === 1) return '#DEDEDE' // alternate rows + } + return null + }, paddingLeft: columnIndex => columnIndex === 2 ? 0 : 2, paddingTop: () => 1, paddingBottom: () => 1 @@ -181,6 +248,9 @@ function createScheduleTable (markerColor, rows, expandAssigneeName) { } export function generateSchedule (weeks, month) { + const language = store.getters['schedule/language'] + const translation = SCHEDULE_TRANSLATIONS[language] + if (!translation) throw new Error('Translations not created for the selected language') const stack = [] const docDefinition = { info: { @@ -200,15 +270,15 @@ export function generateSchedule (weeks, month) { stack: [ { columns: [ - { text: 'CANTON CONGREGATION', width: 160, margin: [0, 8, 0, 0], bold: true }, - { text: 'Our Christian Life & Ministry Schedule', alignment: 'right', fontSize: 17, bold: true } + { text: translation.group, width: 160, margin: [0, 8, 0, 0], bold: true }, + { text: translation.header, alignment: 'right', fontSize: 17, bold: true } ] } ] }, footer (currentPage) { const startingWeek = currentPage * 2 - 1 - const text = startingWeek === weeks.length ? `WEEK ${startingWeek}` : `WEEKS ${startingWeek} & ${startingWeek + 1}` + const text = startingWeek === weeks.length ? `${translation.week} ${startingWeek}` : `${translation.weeks} ${startingWeek} & ${startingWeek + 1}` return { text, margin: [0, 0, 44, 36], alignment: 'right', bold: true } }, content: [ @@ -217,7 +287,6 @@ export function generateSchedule (weeks, month) { } stack.push(createScheduleSeparator(false)) - const language = store.getters['schedule/language'] weeks.forEach((baseWeek, index) => { const { date } = baseWeek const week = baseWeek[language] @@ -226,7 +295,8 @@ export function generateSchedule (weeks, month) { const assignmentMap = Object.entries(assignments) .reduce((acc, [k, v]) => { if (!v) return acc - const a = v.inherit ? baseWeek.en.assignments[k] : v + const { assignee, assistant } = baseWeek.en.assignments[k] + const a = v.inherit ? { ...v, assignee, assistant } : v return Object.assign(acc, { [k]: a }) }, {}) const { @@ -246,39 +316,44 @@ export function generateSchedule (weeks, month) { if (index > 0 && index % 2 === 0) stack.push(createScheduleSeparator(true)) const [, month, day] = date.split('-') const titleDay = day.charAt(0) === '0' ? day.charAt(1) : day - const titleMonth = MONTHS[+month - 1] + const titleMonth = translation.months[+month - 1] let titleText = `${titleDay} ${titleMonth}` - if (weeklyBibleReading) titleText += ` | WEEKLY BIBLE READING: ${weeklyBibleReading}` + if (weeklyBibleReading) titleText += ` | ${translation.weeklyBibleReading}: ${weeklyBibleReading}` stack.push({ text: titleText, fontSize: 14, bold: true }) // Just add a block of text for assembly weeks if (type === WEEK_TYPES.assembly.value || type === WEEK_TYPES.memorial.value) { - const blockText = type === WEEK_TYPES.assembly.value ? 'Assembly Week' : 'Memorial Week' - stack.push({ text: 'No Meeting', fontSize: 32, bold: true, alignment: 'center', margin: [0, 132, 0, 12] }) + const blockText = type === WEEK_TYPES.assembly.value ? translation.assemblyWeek : translation.memorialWeek + stack.push({ text: translation.noMeeting, fontSize: 32, bold: true, alignment: 'center', margin: [0, 132, 0, 12] }) stack.push({ text: blockText, fontSize: 18, alignment: 'center', margin: [0, 0, 0, 132] }) stack.push(createScheduleSeparator()) return } - stack.push({ text: 'Time Off', bold: true, decoration: 'underline', alignment: 'right' }) + stack.push({ + columns: [ + { width: '*', text: '' }, + { width: 28, text: translation.timeOff, bold: true, decoration: 'underline', alignment: 'center' } + ] + }) // Introduction Section stack.push(createScheduleTable(COLORS.TREASURES, [ - [setTime('7:00'), songs[0], 'Prayer:', getScheduleAssignees(openingPrayer), addTime(5)], - [timer, 'Opening Comments (3 min.)', 'Chairman:', getScheduleAssignees(chairman), addTime(3)] + [setTime(translation.startTime), songs[0], translation.prayer + ':', getScheduleAssignees(openingPrayer), addTime(5), openingPrayer.inherit], + [timer, translation.openingComments + ' (3 min.)', translation.chairman + ':', getScheduleAssignees(chairman), addTime(3), chairman.inherit] ])) // TREASURES Section - stack.push(createScheduleSubheader('TREASURES FROM GOD\'S WORD', COLORS.TREASURES)) - const bibleReadingTitle = `Bible Reading (${bibleReading.time}): ${bibleReading.title}` + stack.push(createScheduleSubheader(translation.treasures, COLORS.TREASURES)) + const bibleReadingTitle = `${translation.bibleReading} (${bibleReading.time}): ${bibleReading.title}` stack.push(createScheduleTable(COLORS.MINISTRY, [ - [timer, getAssignmentTitle(highlights), null, getScheduleAssignees(highlights), addTime(highlights.time)], - [timer, 'Digging for Spiritual Gems (10 min.)', null, getScheduleAssignees(gems), addTime(gems.time)], - [timer, bibleReadingTitle, null, getScheduleAssignees(bibleReading), addTime(bibleReading.time)] + [timer, getAssignmentTitle(highlights), null, getScheduleAssignees(highlights), addTime(highlights.time), highlights.inherit], + [timer, translation.gems + ' (10 min.)', null, getScheduleAssignees(gems), addTime(gems.time), gems.inherit], + [timer, bibleReadingTitle, null, getScheduleAssignees(bibleReading), addTime(bibleReading.time), bibleReading.inherit] ])) // MINISTRY Section - stack.push(createScheduleSubheader('APPLY YOURSELF TO THE FIELD MINISTRY', COLORS.MINISTRY)) + stack.push(createScheduleSubheader(translation.ministry, COLORS.MINISTRY)) const ministryTableRows = [] for (let i = 1; i <= 4; i++) { const studentTalk = assignmentMap['studentTalk' + i] @@ -286,33 +361,34 @@ export function generateSchedule (weeks, month) { ministryTableRows.push(null) continue } - let assigneeTitle = 'Student/Assistant:' + let assigneeTitle = `${translation.student}/${translation.assistant}:` if (studentTalk.type === 'ministryVideo') assigneeTitle = '' - if (studentTalk.type === 'studentTalk') assigneeTitle = 'Student:' - ministryTableRows.push([timer, getAssignmentTitle(studentTalk), assigneeTitle, getScheduleAssignees(studentTalk), addTime(studentTalk.time)]) + if (studentTalk.type === 'studentTalk') assigneeTitle = translation.student + ':' + ministryTableRows.push([timer, getAssignmentTitle(studentTalk), assigneeTitle, getScheduleAssignees(studentTalk), addTime(studentTalk.time), studentTalk.inherit]) } stack.push(createScheduleTable(COLORS.MINISTRY, ministryTableRows, true)) // LIVING Section - stack.push(createScheduleSubheader('LIVING AS CHRISTIANS', COLORS.LIVING)) + stack.push(createScheduleSubheader(translation.living, COLORS.LIVING)) + setTime(translation.startTime) const livingTableRows = [ - [setTime('7:47'), songs[1], null, null, addTime(5)], - [timer, getAssignmentTitle(serviceTalk1), null, getScheduleAssignees(serviceTalk1), addTime(serviceTalk1.time)], + [addTime(47), songs[1], null, null, addTime(5), chairman.inherit], + [timer, getAssignmentTitle(serviceTalk1), null, getScheduleAssignees(serviceTalk1), addTime(serviceTalk1.time), serviceTalk1.inherit], null ] - if (serviceTalk2) livingTableRows[2] = [timer, getAssignmentTitle(serviceTalk2), null, getScheduleAssignees(serviceTalk2), addTime(serviceTalk2.time)] + if (serviceTalk2) livingTableRows[2] = [timer, getAssignmentTitle(serviceTalk2), null, getScheduleAssignees(serviceTalk2), addTime(serviceTalk2.time), serviceTalk2.inherit] if (type === WEEK_TYPES.coVisit.value) { livingTableRows.push( - [timer, 'Review/Preview/Announcements (3 min.)', 'Chairman:', getScheduleAssignees(chairman), addTime(3)], - [timer, coTitle + ' (30 min.)', 'Circuit Overseer:', coName, addTime(30)], - [timer, songs[2], 'Prayer:', getScheduleAssignees(closingPrayer), addTime(5)] + [timer, translation.review + ' (3 min.)', translation.chairman + ':', getScheduleAssignees(chairman), addTime(3), chairman.inherit], + [timer, coTitle + ' (30 min.)', translation.co + ':', coName, addTime(30), true], + [timer, songs[2], translation.prayer + ':', getScheduleAssignees(closingPrayer), addTime(5), closingPrayer.inherit] ) } else { livingTableRows.push( - [timer, 'Congregation Bible Study (30 min.)', 'Conductor:', getScheduleAssignees(congregationBibleStudy), addTime(30)], - [null, congregationBibleStudy.title, 'Reader:', getScheduleAssignees(reader), null], - [timer, 'Review/Preview/Announcements (3 min.)', 'Chairman:', getScheduleAssignees(chairman), addTime(3)], - [timer, songs[2], 'Prayer:', getScheduleAssignees(closingPrayer), addTime(5)] + [timer, translation.cbs + ' (30 min.)', translation.conductor + ':', getScheduleAssignees(congregationBibleStudy), addTime(30), congregationBibleStudy.inherit], + [null, congregationBibleStudy.title, translation.reader + ':', getScheduleAssignees(reader), null, reader.inherit], + [timer, translation.review + ' (3 min.)', translation.chairman + ':', getScheduleAssignees(chairman), addTime(3), chairman.inherit], + [timer, songs[2], translation.prayer + ':', getScheduleAssignees(closingPrayer), addTime(5), closingPrayer.inherit] ) } const livingTable = createScheduleTable(COLORS.LIVING, livingTableRows) @@ -327,7 +403,7 @@ export function generateSchedule (weeks, month) { function createSlip (translation, assignment, date = '') { const { title, type, assignee, assistant, studyPoint } = assignment || {} const [y, m, d] = date.split('-') - const prettyDate = [d, MONTHS[+m - 1], y].join(' ') + const prettyDate = [d, translation.months[+m - 1], y].join(' ') return { width: '50%', margin: [32, translation.verticalPadding, 32, translation.verticalPadding],