From 36eb7edde14a124caaaaa3ef390f4a04bd0139b7 Mon Sep 17 00:00:00 2001 From: PedroAntunesCosta <47991446+PedroAntunesCosta@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:58:08 -0300 Subject: [PATCH] fix(localization): add logs to try and fix localization --- src/components/locale-switcher/index.tsx | 3 +++ src/pages/_app.tsx | 7 +++++++ src/pages/announcements/[slug].tsx | 2 ++ src/pages/announcements/index.tsx | 9 ++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/locale-switcher/index.tsx b/src/components/locale-switcher/index.tsx index 4dad49ae..3b526e7d 100644 --- a/src/components/locale-switcher/index.tsx +++ b/src/components/locale-switcher/index.tsx @@ -114,6 +114,9 @@ export default function LocaleSwitcher() { const { locale: currentLocale, setLocale } = useContext(LibraryContext) type LocaleType = typeof currentLocale + console.log('****************** (locale-switcher) currentLocale') + console.log(currentLocale) + const handleOptionClick = async (option: string) => { const chosenLocale = option as LocaleType const currentPath = window.location.pathname diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index fa6392a5..442e30bd 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -27,6 +27,13 @@ function MyApp({ Component, pageProps }: Props) { const currentLocale = locale ?? 'en' const messages = getMessages() + console.log('***********(_app) locale') + console.log(locale) + console.log('***********(_app) currentLocale') + console.log(currentLocale) + // console.log('***********(_app) messages[currentLocale]') + // console.log(messages[currentLocale]) + return ( diff --git a/src/pages/announcements/[slug].tsx b/src/pages/announcements/[slug].tsx index 384ec71d..aa6d7d0d 100644 --- a/src/pages/announcements/[slug].tsx +++ b/src/pages/announcements/[slug].tsx @@ -322,6 +322,8 @@ export const getStaticProps: GetStaticProps = async ({ getParents(keyPath, 'slug', flattenedSidebar, currentLocale, parentsArray) parentsArray.push(slug) } + console.log('------- (announcements/[slug]sectionSelected') + console.log(sectionSelected) return { props: { diff --git a/src/pages/announcements/index.tsx b/src/pages/announcements/index.tsx index e2722ff7..70ff819a 100644 --- a/src/pages/announcements/index.tsx +++ b/src/pages/announcements/index.tsx @@ -21,6 +21,7 @@ import AnnouncementCard from 'components/announcement-card' import { sortBy } from 'utils/constants' import SearchIcon from 'components/icons/search-icon' import Input from 'components/input' +import { LibraryContext } from '@vtexdocs/components' interface Props { sidebarfallback: any //eslint-disable-line @@ -42,6 +43,12 @@ const AnnouncementsPage: NextPage = ({ announcementsData, branch }) => { const [page, setPage] = useState({ curr: 1, total: 1 }) const [sortByValue, setSortByValue] = useState('newest') + const localeLib = useContext(LibraryContext).locale + console.log('-------------- (anouncements index) localeLib') + console.log(localeLib) + console.log('-------------- (anouncements index) intl.locale') + console.log(intl.locale) + const filteredResult = useMemo(() => { const data = announcementsData .filter((announcement) => announcement.status === 'PUBLISHED') @@ -154,7 +161,7 @@ export const getStaticProps: GetStaticProps = async ({ previewData, }) => { const sidebarfallback = await getNavigation() - const sectionSelected = 'Announcements' + const sectionSelected = 'News' const previewBranch = preview && JSON.parse(JSON.stringify(previewData)).hasOwnProperty('branch') ? JSON.parse(JSON.stringify(previewData)).branch