【问题标题】:Angular localization by culture文化角度本地化
【发布时间】:2019-08-01 02:47:19
【问题描述】:

我已经成功构建了一个 Angular 国际化项目,但是我现在想通过文化来实现它,我的意思不仅仅是 es,而是 es-AR 或 en-NZ。

这些是我在angular.js 文件中的西班牙语和英语配置:

"build": {
    ...
    "configurations": {
        ...
        "production-es": {
            "optimization": true,
            "outputHashing": "all",
            "outputPath": "dist/browser/es/",
            "sourceMap": false,
            "extractCss": true,
            "namedChunks": false,
            "aot": true,
            "extractLicenses": true,
            "vendorChunk": false,
            "buildOptimizer": true,
            "fileReplacements": [
              {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
              }
            ],
            "baseHref": "/es/",
            "i18nFile": "src/locale/messages.es.xlf",
            "i18nFormat": "xlf",
            "i18nLocale": "es",
            "i18nMissingTranslation": "error"
        },
        "production-en": {
            "optimization": true,
            "outputHashing": "all",
            "outputPath": "dist/browser/en/",
            "sourceMap": false,
            "extractCss": true,
            "namedChunks": false,
            "aot": true,
            "extractLicenses": true,
            "vendorChunk": false,
            "buildOptimizer": true,
            "fileReplacements": [
              {
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
              }
            ],
            "baseHref": "/en/",
            "i18nFile": "src/locale/messages.en.xlf",
            "i18nFormat": "xlf",
            "i18nLocale": "en",
            "i18nMissingTranslation": "error"
        }
    }
},
"serve": {
    ...
    "configurations": {
        ...
        "es": {
            "browserTarget": "i18n-demo:build:production-es"
        },
        "en": {
            "browserTarget": "i18n-demo:build:production-en"
        }
    }
}

我必须为文化添加什么? 非常感谢提前:)

【问题讨论】:

  • 你已经做了同样的事情,但使用es-AR而不是es

标签: angular localization internationalization


【解决方案1】:

阅读了很多文章后,我发现要按文化(国家或国家的一部分)本地化语言,我需要更改配置。而不是仅仅使用

"i18nLocale": "es",

在 es 的生产中,我们必须使用 es-AR 代替阿根廷西班牙语(例如)。我测试了它,它对我来说工作正常。 我还发现它会自动将货币和日期转换为本地格式。

【讨论】:

    猜你喜欢
    • 2022-10-02
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 2017-08-16
    相关资源
    最近更新 更多