feat(survey-localization): add survey localization files for multiple languages

- Introduced new localization JSON files for Albanian, German, English, Spanish, Portuguese, and Chinese to support the survey feature.
- Each file includes translations for modal titles, button texts, and feedback messages to enhance user experience across different languages.
- Updated the SurveyPromptModal component to utilize these localization entries for improved accessibility and user engagement.
This commit is contained in:
chamikaJ
2025-07-28 16:57:40 +05:30
parent e8d21ee187
commit c2e670c9a2
7 changed files with 109 additions and 21 deletions

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "Ndihmoni të përmirësojmë përvojën tuaj",
"skip": "Kalo për tani",
"previous": "Prapa",
"next": "Tjetra",
"completeSurvey": "Përfundo Anketën",
"submitting": "Duke dërguar përgjigjet tuaja...",
"submitSuccessTitle": "Faleminderit!",
"submitSuccessSubtitle": "Feedback-u juaj na ndihmon të përmirësojmë Worklenz për të gjithë.",
"submitSuccessMessage": "Faleminderit që plotësuat anketën!",
"submitErrorMessage": "Dështoi dërgimi i anketës. Ju lutemi provoni përsëri.",
"submitErrorLog": "Dështoi dërgimi i anketës",
"fetchErrorLog": "Dështoi marrja e anketës"
}

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "Helfen Sie uns, Ihre Erfahrung zu verbessern",
"skip": "Für jetzt überspringen",
"previous": "Zurück",
"next": "Weiter",
"completeSurvey": "Umfrage abschließen",
"submitting": "Ihre Antworten werden übermittelt...",
"submitSuccessTitle": "Danke!",
"submitSuccessSubtitle": "Ihr Feedback hilft uns, Worklenz für alle zu verbessern.",
"submitSuccessMessage": "Danke, dass Sie die Umfrage abgeschlossen haben!",
"submitErrorMessage": "Umfrage konnte nicht übermittelt werden. Bitte versuchen Sie es erneut.",
"submitErrorLog": "Umfrageübermittlung fehlgeschlagen",
"fetchErrorLog": "Umfrageabruf fehlgeschlagen"
}

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "Help Us Improve Your Experience",
"skip": "Skip for now",
"previous": "Previous",
"next": "Next",
"completeSurvey": "Complete Survey",
"submitting": "Submitting your responses...",
"submitSuccessTitle": "Thank you!",
"submitSuccessSubtitle": "Your feedback helps us improve Worklenz for everyone.",
"submitSuccessMessage": "Thank you for completing the survey!",
"submitErrorMessage": "Failed to submit survey. Please try again.",
"submitErrorLog": "Failed to submit survey",
"fetchErrorLog": "Failed to fetch survey"
}

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "Ayúdanos a mejorar tu experiencia",
"skip": "Omitir por ahora",
"previous": "Anterior",
"next": "Siguiente",
"completeSurvey": "Completar encuesta",
"submitting": "Enviando tus respuestas...",
"submitSuccessTitle": "¡Gracias!",
"submitSuccessSubtitle": "Tus comentarios nos ayudan a mejorar Worklenz para todos.",
"submitSuccessMessage": "¡Gracias por completar la encuesta!",
"submitErrorMessage": "No se pudo enviar la encuesta. Por favor, inténtalo de nuevo.",
"submitErrorLog": "Error al enviar la encuesta",
"fetchErrorLog": "Error al obtener la encuesta"
}

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "Ajude-nos a melhorar sua experiência",
"skip": "Pular por enquanto",
"previous": "Anterior",
"next": "Próximo",
"completeSurvey": "Concluir Pesquisa",
"submitting": "Enviando suas respostas...",
"submitSuccessTitle": "Obrigado!",
"submitSuccessSubtitle": "Seu feedback nos ajuda a melhorar o Worklenz para todos.",
"submitSuccessMessage": "Obrigado por completar a pesquisa!",
"submitErrorMessage": "Falha ao enviar a pesquisa. Por favor, tente novamente.",
"submitErrorLog": "Falha ao enviar a pesquisa",
"fetchErrorLog": "Falha ao buscar a pesquisa"
}

View File

@@ -0,0 +1,14 @@
{
"modalTitle": "帮助我们提升您的体验",
"skip": "暂时跳过",
"previous": "上一步",
"next": "下一步",
"completeSurvey": "完成调查",
"submitting": "正在提交您的回答...",
"submitSuccessTitle": "谢谢!",
"submitSuccessSubtitle": "您的反馈帮助我们改进 Worklenz。",
"submitSuccessMessage": "感谢您完成调查!",
"submitErrorMessage": "提交调查失败。请重试。",
"submitErrorLog": "提交调查失败",
"fetchErrorLog": "获取调查失败"
}

View File

@@ -30,11 +30,21 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
const isDarkMode = themeMode === 'dark'; const isDarkMode = themeMode === 'dark';
useEffect(() => { useEffect(() => {
// Check if survey was skipped recently (within 7 days)
const skippedAt = localStorage.getItem('survey_skipped_at');
if (!forceShow && skippedAt) {
const skippedDate = new Date(skippedAt);
const now = new Date();
const diffDays = (now.getTime() - skippedDate.getTime()) / (1000 * 60 * 60 * 24);
if (diffDays < 3) {
return; // Don't show modal if skipped within 7 days
}
}
if (forceShow) { if (forceShow) {
setVisible(true); setVisible(true);
dispatch(resetSurveyData()); dispatch(resetSurveyData());
dispatch(setSurveySubStep(0)); dispatch(setSurveySubStep(0));
// Fetch survey info // Fetch survey info
const fetchSurvey = async () => { const fetchSurvey = async () => {
try { try {
@@ -46,16 +56,13 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
}); });
} }
} catch (error) { } catch (error) {
logger.error('Failed to fetch survey', error); logger.error(t('survey:fetchErrorLog'), error);
} }
}; };
fetchSurvey(); fetchSurvey();
} else if (!loading && hasCompletedSurvey === false) { } else if (!loading && hasCompletedSurvey === false) {
// Reset survey data when modal will be shown
dispatch(resetSurveyData()); dispatch(resetSurveyData());
dispatch(setSurveySubStep(0)); dispatch(setSurveySubStep(0));
// Fetch survey info // Fetch survey info
const fetchSurvey = async () => { const fetchSurvey = async () => {
try { try {
@@ -67,20 +74,17 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
}); });
} }
} catch (error) { } catch (error) {
logger.error('Failed to fetch survey', error); logger.error(t('survey:fetchErrorLog'), error);
} }
}; };
fetchSurvey(); fetchSurvey();
// Show modal after a 5 second delay to not interrupt user immediately // Show modal after a 5 second delay to not interrupt user immediately
const timer = setTimeout(() => { const timer = setTimeout(() => {
setVisible(true); setVisible(true);
}, 5000); }, 5000);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} }
}, [loading, hasCompletedSurvey, dispatch, forceShow]); }, [loading, hasCompletedSurvey, dispatch, forceShow, t]);
const handleComplete = async () => { const handleComplete = async () => {
try { try {
@@ -143,7 +147,7 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
if (response.done) { if (response.done) {
setSurveyCompleted(true); setSurveyCompleted(true);
appMessage.success('Thank you for completing the survey!'); appMessage.success(t('survey:submitSuccessMessage'));
// Wait a moment before closing // Wait a moment before closing
setTimeout(() => { setTimeout(() => {
@@ -151,11 +155,11 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
refetch(); // Update the survey status refetch(); // Update the survey status
}, 2000); }, 2000);
} else { } else {
throw new Error(response.message || 'Failed to submit survey'); throw new Error(response.message || t('survey:submitErrorMessage'));
} }
} catch (error) { } catch (error) {
logger.error('Failed to submit survey', error); logger.error(t('survey:submitErrorLog'), error);
appMessage.error('Failed to submit survey. Please try again.'); appMessage.error(t('survey:submitErrorMessage'));
} finally { } finally {
setSubmitting(false); setSubmitting(false);
} }
@@ -202,20 +206,20 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
return ( return (
<Modal <Modal
open={visible} open={visible}
title={surveyCompleted ? null : "Help Us Improve Your Experience"} title={surveyCompleted ? null : t('survey:modalTitle')}
onCancel={handleSkip} onCancel={handleSkip}
footer={ footer={
surveyCompleted ? null : ( surveyCompleted ? null : (
<Flex justify="space-between" align="center"> <Flex justify="space-between" align="center">
<div> <div>
<Button onClick={handleSkip}> <Button onClick={handleSkip}>
Skip for now {t('survey:skip')}
</Button> </Button>
</div> </div>
<Flex gap={8}> <Flex gap={8}>
{surveySubStep > 0 && ( {surveySubStep > 0 && (
<Button onClick={handlePrevious}> <Button onClick={handlePrevious}>
Previous {t('survey:previous')}
</Button> </Button>
)} )}
<Button <Button
@@ -224,7 +228,7 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
disabled={!isCurrentStepValid()} disabled={!isCurrentStepValid()}
loading={submitting && surveySubStep === 2} loading={submitting && surveySubStep === 2}
> >
{surveySubStep === 2 ? 'Complete Survey' : 'Next'} {surveySubStep === 2 ? t('survey:completeSurvey') : t('survey:next')}
</Button> </Button>
</Flex> </Flex>
</Flex> </Flex>
@@ -237,13 +241,13 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
{submitting ? ( {submitting ? (
<div style={{ textAlign: 'center', padding: '40px' }}> <div style={{ textAlign: 'center', padding: '40px' }}>
<Spin size="large" /> <Spin size="large" />
<p style={{ marginTop: 16 }}>Submitting your responses...</p> <p style={{ marginTop: 16 }}>{t('survey:submitting')}</p>
</div> </div>
) : surveyCompleted ? ( ) : surveyCompleted ? (
<Result <Result
status="success" status="success"
title="Thank you!" title={t('survey:submitSuccessTitle')}
subTitle="Your feedback helps us improve Worklenz for everyone." subTitle={t('survey:submitSuccessSubtitle')}
/> />
) : ( ) : (
<div style={{ maxHeight: '70vh', overflowY: 'auto' }}> <div style={{ maxHeight: '70vh', overflowY: 'auto' }}>