Skip to content

Commit

Permalink
fix(localization): add logs to try and fix localization
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroAntunesCosta committed Dec 4, 2024
1 parent 3c2ff0d commit 36eb7ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/locale-switcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TrackerProvider>
<IntlProvider locale={currentLocale} messages={messages[currentLocale]}>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/announcements/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
9 changes: 8 additions & 1 deletion src/pages/announcements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,6 +43,12 @@ const AnnouncementsPage: NextPage<Props> = ({ announcementsData, branch }) => {
const [page, setPage] = useState({ curr: 1, total: 1 })
const [sortByValue, setSortByValue] = useState<SortByType>('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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 36eb7ed

Please sign in to comment.