最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why isn't i18next-fs-backend loading translation files from Onedrive? - Stack Overflow

programmeradmin5浏览0评论

I'm trying to load i18next translation files from a directory in OneDrive. When I try to do so, playwright keeps looking for the files in the C:\ drive. Is it imposible to load files from OneDrive? Can anyone tell me what I am doing wrong?

See my code below:

const localePath = path.resolve('./locales');
// resolves correctly to C:\Users\myuserpath\OneDrive - MyStuff\QA-Automation\locales

i18next
    .use(FsBackend)
        .init({
        lng: 'en',
        ns:['signin.page', 'chat.page','session.page', 'landing.page', 'userprofile.page'],   
        FsBackend:{ 
           FsBackendOptions: {loadPath: path.join(localePath, '/{{lng}}/{{ns}}.page.json'),},
        }
    })

//Expected result: 
//Translations should load from C:\Users\myuserpath\OneDrive - MyStuff\QA-Automation\locales\en\NAMESPACEFILE.page.json
//Actual result: 
//[Error: ENOENT: no such file or directory, open 'C:\locales\en\NAMESPACEFILE.page.json'

Other things I have tried:

Using onedrive:

const myOneDrive = process.env.OneDriveCommercial;
const longerpath = path.join(myOneDrive, '/QA-Automation/locales/{{lng}}/{{ns}}.page.json');
i18next
    .use(FsBackend)
    .init({
     //blah blah
        FsBackend:{ FsBackendOptions: {loadPath: longerpath},},
    })

Hardcoding the full path:

const fullpath = 'C:\Users\myuserpath\OneDrive - MyStuff\QA-Automation\locales'
    FsBackend:{ FsBackendOptions: {loadPath: fullpath},},

Hardcoding the full path in init:

FsBackendOptions: {loadPath: 'C:/Users/myuserpath/OneDrive - MyStuff/QA-Automation/locales/{{lng}}/{{ns}}.page.json,},

Swearing:

const dev_reaction = '$#!(#&*$@$!!!'

The result is always the same. It ignores the Onedrive completely, and tries to load from c:\locales\etc.

发布评论

评论列表(0)

  1. 暂无评论