Skip to content

Commit

Permalink
fix(locales): source materials issues for tagalog language
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Dec 10, 2024
1 parent a0d7fed commit 76cd6d9
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 34 deletions.
36 changes: 36 additions & 0 deletions src/services/app/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ const sourcesFormatAndSaveData = async (data: SourceWeekIncomingType[]) => {
assType =
assTypeList.find((type) => type.label === src.mwb_ayf_part1_type)
?.value || 127;

if (
source_lang === 'TG' &&
obj.weekOf >= '2024/01/01' &&
assType === 102
) {
assType = 124;
}

obj.midweek_meeting.ayf_part1 = {
src: { [source_lang]: src.mwb_ayf_part1 },
time: { [source_lang]: src.mwb_ayf_part1_time },
Expand All @@ -114,6 +123,15 @@ const sourcesFormatAndSaveData = async (data: SourceWeekIncomingType[]) => {
assType =
assTypeList.find((type) => type.label === src.mwb_ayf_part2_type)
?.value || 127;

if (
source_lang === 'TG' &&
obj.weekOf >= '2024/01/01' &&
assType === 102
) {
assType = 124;
}

obj.midweek_meeting.ayf_part2 = {
src: { [source_lang]: src.mwb_ayf_part2 },
time: { [source_lang]: src.mwb_ayf_part2_time },
Expand All @@ -126,6 +144,15 @@ const sourcesFormatAndSaveData = async (data: SourceWeekIncomingType[]) => {
assType =
assTypeList.find((type) => type.label === src.mwb_ayf_part3_type)
?.value || 127;

if (
source_lang === 'TG' &&
obj.weekOf >= '2024/01/01' &&
assType === 102
) {
assType = 124;
}

obj.midweek_meeting.ayf_part3 = {
src: { [source_lang]: src.mwb_ayf_part3 },
time: { [source_lang]: src.mwb_ayf_part3_time },
Expand All @@ -138,6 +165,15 @@ const sourcesFormatAndSaveData = async (data: SourceWeekIncomingType[]) => {
assType =
assTypeList.find((type) => type.label === src.mwb_ayf_part4_type)
?.value || 127;

if (
source_lang === 'TG' &&
obj.weekOf >= '2024/01/01' &&
assType === 102
) {
assType = 124;
}

obj.midweek_meeting.ayf_part4 = {
src: { [source_lang]: src.mwb_ayf_part4 },
time: { [source_lang]: src.mwb_ayf_part4_time },
Expand Down
122 changes: 99 additions & 23 deletions src/services/dexie/assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,68 +37,144 @@ export const dbAssignmentUpdate = async () => {
const explainingBeliefsObj: { [language: string]: string } = {};
const dicussionObj: { [language: string]: string } = {};

LANGUAGE_LIST.forEach((lang) => {
const appLang = localStorage.getItem('ui_lang') || 'en';
const langCode =
LANGUAGE_LIST.find((record) => record.locale === appLang)?.code || 'E';

const languages = [{ locale: appLang, code: langCode }];

if (!languages.some((r) => r.locale === 'en'))
languages.push({ locale: 'en', code: 'E' });

for (const lang of languages) {
const langCode = lang.code.toUpperCase();

bReadObj[langCode] = getTranslation({ key: 'tr_bibleReading' });
initCallObj[langCode] = getTranslation({ key: 'tr_initialCall' });
rvObj[langCode] = getTranslation({ key: 'tr_returnVisit' });
bsObj[langCode] = getTranslation({ key: 'tr_bibleStudy' });
talkObj[langCode] = getTranslation({ key: 'tr_talk' });
otherObj[langCode] = getTranslation({ key: 'tr_otherPart' });
icVideoObj[langCode] = getTranslation({ key: 'tr_initialCallVideo' });
rvVideoObj[langCode] = getTranslation({ key: 'tr_returnVisitVideo' });
memorialObj[langCode] = getTranslation({ key: 'tr_memorialInvite' });
bReadObj[langCode] = getTranslation({
key: 'tr_bibleReading',
language: lang.locale,
});
initCallObj[langCode] = getTranslation({
key: 'tr_initialCall',
language: lang.locale,
});
rvObj[langCode] = getTranslation({
key: 'tr_returnVisit',
language: lang.locale,
});
bsObj[langCode] = getTranslation({
key: 'tr_bibleStudy',
language: lang.locale,
});
talkObj[langCode] = getTranslation({
key: 'tr_talk',
language: lang.locale,
});
otherObj[langCode] = getTranslation({
key: 'tr_otherPart',
language: lang.locale,
});
icVideoObj[langCode] = getTranslation({
key: 'tr_initialCallVideo',
language: lang.locale,
});
rvVideoObj[langCode] = getTranslation({
key: 'tr_returnVisitVideo',
language: lang.locale,
});
memorialObj[langCode] = getTranslation({
key: 'tr_memorialInvite',
language: lang.locale,
});
memorialVideoObj[langCode] = getTranslation({
key: 'tr_memorialInviteVideo',
language: lang.code,
language: lang.locale,
});
chairmanMMObj[langCode] = getTranslation({
key: 'tr_chairmanMidweekMeeting',
language: lang.code,
language: lang.locale,
});
prayerMMObj[langCode] = getTranslation({
key: 'tr_prayerMidweekMeeting',
language: lang.locale,
});
tgwTalkObj[langCode] = getTranslation({
key: 'tr_tgwTalk',
language: lang.locale,
});
tgwGemsObj[langCode] = getTranslation({
key: 'tr_tgwGems',
language: lang.locale,
});
lcPartObj[langCode] = getTranslation({
key: 'tr_lcPart',
language: lang.locale,
});
cbsConductorObj[langCode] = getTranslation({
key: 'tr_cbsConductor',
language: lang.locale,
});
cbsReaderObj[langCode] = getTranslation({
key: 'tr_cbsReader',
language: lang.locale,
});
prayerMMObj[langCode] = getTranslation({ key: 'tr_prayerMidweekMeeting' });
tgwTalkObj[langCode] = getTranslation({ key: 'tr_tgwTalk' });
tgwGemsObj[langCode] = getTranslation({ key: 'tr_tgwGems' });
lcPartObj[langCode] = getTranslation({ key: 'tr_lcPart' });
cbsConductorObj[langCode] = getTranslation({ key: 'tr_cbsConductor' });
cbsReaderObj[langCode] = getTranslation({ key: 'tr_cbsReader' });
initCallVariationsObj[langCode] = getTranslation({
key: 'tr_initialCallVariations',
language: lang.locale,
});
rvVariationsObj[langCode] = getTranslation({
key: 'tr_returnVisitVariations',
language: lang.locale,
});
chairmanWMObj[langCode] = getTranslation({
key: 'tr_chairmanWeekendMeeting',
language: lang.locale,
});
prayerWMObj[langCode] = getTranslation({
key: 'tr_prayerWeekendMeeting',
language: lang.locale,
});
speakerObj[langCode] = getTranslation({
key: 'tr_speaker',
language: lang.locale,
});
prayerWMObj[langCode] = getTranslation({ key: 'tr_prayerWeekendMeeting' });
speakerObj[langCode] = getTranslation({ key: 'tr_speaker' });
speakerSymposiumObj[langCode] = getTranslation({
key: 'tr_speakerSymposium',
language: lang.locale,
});
wtStudyReaderObj[langCode] = getTranslation({
key: 'tr_watchtowerStudyReader',
language: lang.locale,
});
wtStudyConductor[langCode] = getTranslation({
key: 'tr_watchtowerStudyConductor',
language: lang.locale,
});
auxClassroomMMObj[langCode] = getTranslation({
key: 'tr_auxClassCounselor',
language: lang.locale,
});
assistantOnlyMMObj[langCode] = getTranslation({ key: 'tr_assistantOnly' });
startingConversationObj[langCode] = getTranslation({
key: 'tr_startingConversation',
language: lang.locale,
});
followingUpObj[langCode] = getTranslation({
key: 'tr_followingUp',
language: lang.locale,
});
followingUpObj[langCode] = getTranslation({ key: 'tr_followingUp' });
makingDisciplesObj[langCode] = getTranslation({
key: 'tr_makingDisciples',
language: lang.locale,
});
explainingBeliefsObj[langCode] = getTranslation({
key: 'tr_explainingBeliefs',
language: lang.locale,
});
dicussionObj[langCode] = getTranslation({ key: 'tr_discussion' });
});
dicussionObj[langCode] = getTranslation({
key: 'tr_discussion',
language: lang.locale,
});
}

await appDb.assignment.clear();

Expand Down
48 changes: 37 additions & 11 deletions src/services/dexie/weekType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LANGUAGE_LIST } from '@constants/index';
import { getTranslation } from '@services/i18n/translation';
import appDb from '@db/appDb';

Expand All @@ -11,17 +10,44 @@ export const dbWeekTypeUpdate = async () => {
const specialTalkWeekObj = {};
const noMeetingWeekObj = {};

LANGUAGE_LIST.forEach((lang) => {
const locale = lang.locale.toUpperCase();
const language = localStorage.getItem('ui_lang') || 'en';

normWeekObj[locale] = getTranslation({ key: 'tr_normalWeek' });
tgWeekObj[locale] = getTranslation({ key: 'tr_circuitOverseerWeek' });
caWeekObj[locale] = getTranslation({ key: 'tr_assemblyWeek' });
coWeekObj[locale] = getTranslation({ key: 'tr_conventionWeek' });
memorialWeekObj[locale] = getTranslation({ key: 'tr_memorialWeek' });
specialTalkWeekObj[locale] = getTranslation({ key: 'tr_specialTalkWeek' });
noMeetingWeekObj[locale] = getTranslation({ key: 'tr_noMeeting' });
});
const languages = [language];

if (!languages.includes('en')) languages.push('en');

for (const lang of languages) {
const locale = lang.toUpperCase();

normWeekObj[locale] = getTranslation({
key: 'tr_normalWeek',
language: lang,
});
tgWeekObj[locale] = getTranslation({
key: 'tr_circuitOverseerWeek',
language: lang,
});
caWeekObj[locale] = getTranslation({
key: 'tr_assemblyWeek',
language: lang,
});
coWeekObj[locale] = getTranslation({
key: 'tr_conventionWeek',
language: lang,
});
memorialWeekObj[locale] = getTranslation({
key: 'tr_memorialWeek',
language: lang,
});
specialTalkWeekObj[locale] = getTranslation({
key: 'tr_specialTalkWeek',
language: lang,
});
noMeetingWeekObj[locale] = getTranslation({
key: 'tr_noMeeting',
language: lang,
});
}

await appDb.week_type.clear();

Expand Down
10 changes: 10 additions & 0 deletions src/services/worker/backupUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,16 @@ const dbRestoreSources = async (
const newItem = structuredClone(localItem);
syncFromRemote(newItem, remoteItem);

// give priority to local type
newItem.midweek_meeting.ayf_part1.type =
localItem.midweek_meeting.ayf_part1.type;
newItem.midweek_meeting.ayf_part2.type =
localItem.midweek_meeting.ayf_part2.type;
newItem.midweek_meeting.ayf_part3.type =
localItem.midweek_meeting.ayf_part3.type;
newItem.midweek_meeting.ayf_part4.type =
localItem.midweek_meeting.ayf_part4.type;

dataToUpdate.push(newItem);
}
}
Expand Down

0 comments on commit 76cd6d9

Please sign in to comment.