From cfb01de80caa84d9042109903cbfc9fc98916fab Mon Sep 17 00:00:00 2001 From: je1999 Date: Sat, 11 May 2024 13:54:20 -0400 Subject: [PATCH] feat(language): add language change button The implemented functionality added a language button with options for Spanish (ES) and English (EN). --- public/assets/en-language.svg | 9 +++++ public/assets/es-language.svg | 9 +++++ src/components/layout/languageSelector.tsx | 40 ++++++++++++++++++++++ src/components/layout/navBar.tsx | 3 +- src/dictionaries/en.json | 1 + src/dictionaries/es.json | 1 + 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 public/assets/en-language.svg create mode 100644 public/assets/es-language.svg create mode 100644 src/components/layout/languageSelector.tsx diff --git a/public/assets/en-language.svg b/public/assets/en-language.svg new file mode 100644 index 00000000..e50a5988 --- /dev/null +++ b/public/assets/en-language.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/assets/es-language.svg b/public/assets/es-language.svg new file mode 100644 index 00000000..fc6bcd0b --- /dev/null +++ b/public/assets/es-language.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/components/layout/languageSelector.tsx b/src/components/layout/languageSelector.tsx new file mode 100644 index 00000000..01aff3c9 --- /dev/null +++ b/src/components/layout/languageSelector.tsx @@ -0,0 +1,40 @@ +import Image from 'next/image'; + +import ESLanguage from '@public/assets/es-language.svg'; +import ENLanguage from '@public/assets/en-language.svg'; +import { useLanguage } from '@/app/[lang]/provider'; +import { ButtonApp } from '../elements/button'; + +export const LanguageSelector = () => { + const { intl } = useLanguage(); + + const handleLanguageChange = () => { + return window.location.href = `/${intl.language === 'en' ? 'es' : 'en'}/identification`; + }; + + return ( +
+ + } + onClick={() => handleLanguageChange()} + > + {intl.language === 'en' + ? + 'Español' + : + 'English' + } + +
+ ); +} diff --git a/src/components/layout/navBar.tsx b/src/components/layout/navBar.tsx index 23b68751..235b425b 100644 --- a/src/components/layout/navBar.tsx +++ b/src/components/layout/navBar.tsx @@ -11,6 +11,7 @@ import styles from './styles.module.css'; import { useLanguage } from '@/app/[lang]/provider'; import { ButtonApp } from '../elements/button'; +import { LanguageSelector } from './languageSelector'; export default function Index() { const { intl } = useLanguage(); @@ -41,8 +42,8 @@ export default function Index() { color="primary" style={{ display: 'none' }} /> + window.open('https://mi.cuentaunica.gob.do/ui/login') diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index 2c73e7d9..b8faca51 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -1,4 +1,5 @@ { + "language": "en", "common": { "title": "Cuenta Única Ciudadana", "hello": "Hello", diff --git a/src/dictionaries/es.json b/src/dictionaries/es.json index a41dc6f9..6cca922c 100644 --- a/src/dictionaries/es.json +++ b/src/dictionaries/es.json @@ -1,4 +1,5 @@ { + "language": "es", "common": { "title": "Cuenta Única Ciudadana", "hello": "Hola",