[i18next可在开发服务器上使用,但不能在Azure应用服务中使用

问题描述 投票:0回答:2

我制作了一个React应用程序,使用i18next包对其进行了翻译。因为已经安装了i18n-backend模块,所以我将文件定位在目录“ public / locales / en / translation.json”中。在我开发时,这很好。但是,如果我将其部署到AZURE App-Service,则会向我发出警告“缺少键”。

仅提:

这些文件确实存在于App-Service的目录中,并且相同的路径。

但是我无法通过URL访问它们

“ myApplicationURL / locales / en / translation.json”。enter image description here

import i18n from 'i18next';
import Backend from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

const fallbackLng = ['en'];
const availableLanguages = ['en', 'de'];

i18n
    .use(Backend)

    .use(LanguageDetector)

    .use(initReactI18next)

    .init({
        fallbackLng,
        debug: true,
        whitelist: availableLanguages,

        interpolation: {
            escapeValue: false
        },
    });

export default i18n;

有人遇到过这个问题吗?老实说,我没有办法解决这个问题。

谢谢

reactjs azure i18next
2个回答
1
投票

运行本地反应(webpack)将dev / server服务到本地/ public文件夹->服务器上不存在此魔力...没有配置,服务器不提供文件...


0
投票

现在可以使用。如果您有相同的问题,只需插入:

<staticContent>
    <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

进入web.config文件。这允许服务器提供json文件。

© www.soinside.com 2019 - 2024. All rights reserved.