typescript 使用模板进行国际化

63lcw9qa  于 2023-01-03  发布在  TypeScript
关注(0)|答案(1)|浏览(167)

嘿,所以我一直试图做我的模具项目的国际化,但它不工作,我不知道出了什么问题,这是所有我得到的

我知道404意味着它无法找到文件或其他什么,但我遵循了这些文章,他们都没有这个问题,我做了确切的步骤,因为在这些文章https://medium.com/stencil-tricks/implementing-internationalisation-i18n-with-stencil-5e6559554117https://dev.to/teamhive/using-i18n-translations-within-stencil-components-4n30
这是我的包裹. json

{
  "name": "iii",
  "version": "0.0.1",
  "description": "Stencil Component Starter",
  "main": "dist/index.cjs.js",
  "module": "dist/index.js",
  "es2015": "dist/esm/index.mjs",
  "es2017": "dist/esm/index.mjs",
  "types": "dist/types/index.d.ts",
  "collection": "dist/collection/collection-manifest.json",
  "collection:main": "dist/collection/index.js",
  "unpkg": "dist/iii/iii.esm.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ionic-team/stencil-component-starter.git"
  },
  "files": [
    "dist/",
    "loader/"
  ],
  "scripts": {
    "build": "stencil build --docs",
    "start": "stencil build --dev --watch --serve",
    "test": "stencil test --spec --e2e",
    "test.watch": "stencil test --spec --e2e --watchAll",
    "generate": "stencil generate"
  },
  "dependencies": {
    "@stencil/core": "^2.13.0"
  },
  "devDependencies": {
    "@types/jest": "^27.0.3",
    "jest": "^27.4.5",
    "jest-cli": "^27.4.5",
    "puppeteer": "^10.0.0"
  },
  "license": "MIT"
}`

stencil.config.json

import { Config } from '@stencil/core';

export const config: Config = {
  namespace: 'iii',
  outputTargets: [
    {
      type: 'dist',
      esmLoaderPath: '../loader',
    },
    {
      type: 'dist-custom-elements',
    },
    {
      type: 'docs-readme',
    },
    {
      type: 'www',
      serviceWorker: null, // disable service workers
    },
  ],
  copy: [
    {
      src: "**/*.i18n.*.json",
      dest: "i18n"
    }
  ]
};
`

至于代码,我写在给定的文章,我真的需要一些提示或任何文章或帮助,任何可以帮助我做模具国际化的确切代码

ssgvzors

ssgvzors1#

文件似乎未复制,或未复制到预期位置。请验证它们是否确实位于dist和/或www文件夹中。
此外,由于模板2,复制任务已被移动到输出目标配置中(请参阅中断更改),因此请尝试将其移动到www输出目标配置中:

import { Config } from '@stencil/core';

export const config: Config = {
  namespace: 'iii',
  outputTargets: [
    {
      type: 'dist',
      esmLoaderPath: '../loader',
    },
    {
      type: 'dist-custom-elements',
    },
    {
      type: 'docs-readme',
    },
    {
      type: 'www',
      serviceWorker: null, // disable service workers
      copy: [
        {
          src: "**/*.i18n.*.json",
          dest: "i18n"
        }
      ],
    },
  ],
};

相关问题