Skip to content

Commit

Permalink
update the js code to display the banner correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ntluong95 committed May 31, 2024
1 parent b19fe51 commit fb8533d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@

<script>

// Function to extract the last two characters from the URL path to determine the language, adjusting for .html extension
// Function to extract the last two characters from the URL path
function getLanguageFromURL() {
let path = window.location.pathname;
const path = window.location.pathname.split('/');

// Check if the URL ends with .html and remove it
if (path.endsWith('.html')) {
path = path.substring(0, path.length - 5);
if (path.length > 1) {
return path[1]; // Assume the language code is the second segment
}

// Extract the last two characters for the language code
const lang = path.substr(-2);
return lang;
return '';
}

const language = getLanguageFromURL();
const supportedLanguages = ['fr', 'es', 'vn', 'jp', 'pt', 'tr', 'ru'];
const supportedLanguages = ['fr', 'es', 'vn', 'jp', 'pt', 'tr', 'ru', 'en'];
const defaultLanguage = 'en';
const isSupportedLanguage = supportedLanguages.includes(language);

Expand Down

0 comments on commit fb8533d

Please sign in to comment.