Skip to content

Commit

Permalink
Refactor FooterLayout component and add GTranslate component
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanshahriar32 committed Oct 13, 2024
1 parent c4b5532 commit 2f610e0
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/global/Footer/FooterLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { PortableTextBlock } from 'next-sanity'

import { CustomPortableText } from '@/components//shared/CustomPortableText'
import type { SettingsPayload } from '@/types'
import GTranslate from './gTranslate'

interface FooterProps {
data: SettingsPayload
Expand All @@ -17,6 +18,9 @@ export default function Footer(props: FooterProps) {
value={footer}
/>
)}
<div className="flex w-full flex-row flex-wrap items-center justify-center">
<GTranslate />
</div>
</footer>
)
}
32 changes: 32 additions & 0 deletions components/global/Footer/gTranslate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import React from "react";
import { Helmet } from "react-helmet";
function GTranslate() {
return (
<div>
{/* Your component content here */}

{/* Add the following Helmet component to include the script in the head */}
<Helmet>
<script type="text/javascript">
{`
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{pageLanguage: 'en'},
'google_translate_element'
);
}
`}
</script>
<script
async
type="text/javascript"
src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"
></script>
</Helmet>
<div id="google_translate_element"></div>
</div>
);
}

export default GTranslate;
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"next-sanity": "9.5.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-helmet": "^6.1.0",
"react-hooks-global-state": "^2.1.0",
"react-photo-view": "^1.2.6",
"react-swipeable": "^7.0.0",
Expand Down

0 comments on commit 2f610e0

Please sign in to comment.