Skip to content

Commit

Permalink
feat: use lang of navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
felixleo22 committed Oct 23, 2024
1 parent 839fbf9 commit b1c8ab9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr">
<html>

<head>
<title>ezPAARSE ezMESURE - les données d’usages des ressources numériques</title>
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/i18n.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { createI18n } from "vue-i18n";
import messages from '@intlify/unplugin-vue-i18n/messages'

function getBrowserLocale() {
const navigatorLang = navigator.languages ? navigator.languages[0] : navigator.language
console.log(navigatorLang);
return navigatorLang ? navigatorLang.split('-')[0].toLowerCase() : null
}

const locale = getBrowserLocale()

export default createI18n({
locale: (import.meta.env.VITE_DEFAULT_LOCALE || 'FR').toLowerCase(),
fallbackLocale: import.meta.env.VITE_FALLBACK_LOCALE,
locale,
fallbackLocale: 'en',
legacy: false,
messages
})

0 comments on commit b1c8ab9

Please sign in to comment.