From c2e670c9a28f8ee57a9eb31362c6b12541f51867 Mon Sep 17 00:00:00 2001 From: chamikaJ Date: Mon, 28 Jul 2025 16:57:40 +0530 Subject: [PATCH] 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. --- .../public/locales/alb/survey.json | 14 ++++++ .../public/locales/de/survey.json | 14 ++++++ .../public/locales/en/survey.json | 14 ++++++ .../public/locales/es/survey.json | 14 ++++++ .../public/locales/pt/survey.json | 14 ++++++ .../public/locales/zh/survey.json | 14 ++++++ .../components/survey/SurveyPromptModal.tsx | 46 ++++++++++--------- 7 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 worklenz-frontend/public/locales/alb/survey.json create mode 100644 worklenz-frontend/public/locales/de/survey.json create mode 100644 worklenz-frontend/public/locales/en/survey.json create mode 100644 worklenz-frontend/public/locales/es/survey.json create mode 100644 worklenz-frontend/public/locales/pt/survey.json create mode 100644 worklenz-frontend/public/locales/zh/survey.json diff --git a/worklenz-frontend/public/locales/alb/survey.json b/worklenz-frontend/public/locales/alb/survey.json new file mode 100644 index 00000000..65713542 --- /dev/null +++ b/worklenz-frontend/public/locales/alb/survey.json @@ -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" +} \ No newline at end of file diff --git a/worklenz-frontend/public/locales/de/survey.json b/worklenz-frontend/public/locales/de/survey.json new file mode 100644 index 00000000..92b7c8ce --- /dev/null +++ b/worklenz-frontend/public/locales/de/survey.json @@ -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" +} \ No newline at end of file diff --git a/worklenz-frontend/public/locales/en/survey.json b/worklenz-frontend/public/locales/en/survey.json new file mode 100644 index 00000000..d6b13b3f --- /dev/null +++ b/worklenz-frontend/public/locales/en/survey.json @@ -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" +} \ No newline at end of file diff --git a/worklenz-frontend/public/locales/es/survey.json b/worklenz-frontend/public/locales/es/survey.json new file mode 100644 index 00000000..be30d755 --- /dev/null +++ b/worklenz-frontend/public/locales/es/survey.json @@ -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" +} \ No newline at end of file diff --git a/worklenz-frontend/public/locales/pt/survey.json b/worklenz-frontend/public/locales/pt/survey.json new file mode 100644 index 00000000..250eaf90 --- /dev/null +++ b/worklenz-frontend/public/locales/pt/survey.json @@ -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" +} \ No newline at end of file diff --git a/worklenz-frontend/public/locales/zh/survey.json b/worklenz-frontend/public/locales/zh/survey.json new file mode 100644 index 00000000..b472db9c --- /dev/null +++ b/worklenz-frontend/public/locales/zh/survey.json @@ -0,0 +1,14 @@ +{ + "modalTitle": "帮助我们提升您的体验", + "skip": "暂时跳过", + "previous": "上一步", + "next": "下一步", + "completeSurvey": "完成调查", + "submitting": "正在提交您的回答...", + "submitSuccessTitle": "谢谢!", + "submitSuccessSubtitle": "您的反馈帮助我们改进 Worklenz。", + "submitSuccessMessage": "感谢您完成调查!", + "submitErrorMessage": "提交调查失败。请重试。", + "submitErrorLog": "提交调查失败", + "fetchErrorLog": "获取调查失败" +} \ No newline at end of file diff --git a/worklenz-frontend/src/components/survey/SurveyPromptModal.tsx b/worklenz-frontend/src/components/survey/SurveyPromptModal.tsx index 7f368261..334d08b2 100644 --- a/worklenz-frontend/src/components/survey/SurveyPromptModal.tsx +++ b/worklenz-frontend/src/components/survey/SurveyPromptModal.tsx @@ -30,11 +30,21 @@ export const SurveyPromptModal: React.FC = ({ forceShow const isDarkMode = themeMode === 'dark'; 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) { setVisible(true); dispatch(resetSurveyData()); dispatch(setSurveySubStep(0)); - // Fetch survey info const fetchSurvey = async () => { try { @@ -46,16 +56,13 @@ export const SurveyPromptModal: React.FC = ({ forceShow }); } } catch (error) { - logger.error('Failed to fetch survey', error); + logger.error(t('survey:fetchErrorLog'), error); } }; - fetchSurvey(); } else if (!loading && hasCompletedSurvey === false) { - // Reset survey data when modal will be shown dispatch(resetSurveyData()); dispatch(setSurveySubStep(0)); - // Fetch survey info const fetchSurvey = async () => { try { @@ -67,20 +74,17 @@ export const SurveyPromptModal: React.FC = ({ forceShow }); } } catch (error) { - logger.error('Failed to fetch survey', error); + logger.error(t('survey:fetchErrorLog'), error); } }; - fetchSurvey(); - // Show modal after a 5 second delay to not interrupt user immediately const timer = setTimeout(() => { setVisible(true); }, 5000); - return () => clearTimeout(timer); } - }, [loading, hasCompletedSurvey, dispatch, forceShow]); + }, [loading, hasCompletedSurvey, dispatch, forceShow, t]); const handleComplete = async () => { try { @@ -143,7 +147,7 @@ export const SurveyPromptModal: React.FC = ({ forceShow if (response.done) { setSurveyCompleted(true); - appMessage.success('Thank you for completing the survey!'); + appMessage.success(t('survey:submitSuccessMessage')); // Wait a moment before closing setTimeout(() => { @@ -151,11 +155,11 @@ export const SurveyPromptModal: React.FC = ({ forceShow refetch(); // Update the survey status }, 2000); } else { - throw new Error(response.message || 'Failed to submit survey'); + throw new Error(response.message || t('survey:submitErrorMessage')); } } catch (error) { - logger.error('Failed to submit survey', error); - appMessage.error('Failed to submit survey. Please try again.'); + logger.error(t('survey:submitErrorLog'), error); + appMessage.error(t('survey:submitErrorMessage')); } finally { setSubmitting(false); } @@ -202,20 +206,20 @@ export const SurveyPromptModal: React.FC = ({ forceShow return (
{surveySubStep > 0 && ( )} @@ -237,13 +241,13 @@ export const SurveyPromptModal: React.FC = ({ forceShow {submitting ? (
-

Submitting your responses...

+

{t('survey:submitting')}

) : surveyCompleted ? ( ) : (