Skip to content

Commit

Permalink
modify browser lang detector and index.js
Browse files Browse the repository at this point in the history
Signed-off-by: Ansh Goyal <[email protected]>
  • Loading branch information
anshgoyalevil committed Aug 7, 2023
1 parent a4a2bbf commit 962ad49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/browserLanguageDetector.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { i18n } = require("./../next-i18next-static-site.config");

function browserLanguageDetector() {
// Converts languages like 'en-US' to 'en'
const convertLanguageCode = (code) => {
const baseLanguageCode = code.split('-')[0];
return baseLanguageCode;
};

// Converts languages like 'en-US' to 'en'
const convertLanguageCode = (code) => {
const baseLanguageCode = code.split('-')[0];
return baseLanguageCode;
};
function browserLanguageDetector() {

// Fetch the language stored inside localStorage
const localStorageLanguage = localStorage.getItem('i18nLang');
Expand Down
3 changes: 2 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import NewsroomSection from '../components/newsroom/NewsroomSection'
import { languageDetection } from "../lib/i18n";

function HomePage() {
languageDetection();
//To be enabled in a future PR
//languageDetection();
return (
<>
<Head />
Expand Down

0 comments on commit 962ad49

Please sign in to comment.