feat(core): update

This commit is contained in:
2026-06-21 20:20:20 +03:30
parent 4d995a61af
commit 58b027813d
15 changed files with 232 additions and 113 deletions

View File

@@ -2,23 +2,25 @@ import { match } from '@formatjs/intl-localematcher'
import Negotiator from 'negotiator'
// Get the preferred locale, similar to the above or using a library
let locales = ['en', 'fa']
function getLocale(request) {
let headers = { 'accept-language': 'en-US,en;q=0.5' }
let languages = new Negotiator({ headers }).languages()
let defaultLocale = 'en-US';
let domains= [
{
domain: "rahavardmgp.ir",
defaultLocale: 'fa'
},
{
domain: "rahavardmgp.com",
defaultLocale: 'en'
}
]
return match(languages, locales, defaultLocale, domains) // -> 'en-US'
const locales = ['en', 'fa']
function getLocale(request) {
const hostname = request.headers.get('host')?.split(':')[0]
if (hostname === 'rahavardmgp.ir' || hostname === 'www.rahavardmgp.ir') {
return 'fa'
}
if (hostname === 'rahavardmgp.com' || hostname === 'www.rahavardmgp.com') {
return 'en'
}
const headers = {
'accept-language': request.headers.get('accept-language') || 'fa'
}
const languages = new Negotiator({ headers }).languages()
return match(languages, locales, 'fa')
}
export function middleware(request) {