Angular/i18n 是 Angular 官方提供的一个国际化(i18n)工具,它可以帮助开发者轻松实现多语言支持。

语言风格

如果您访问的是 /en/xxx 类型的路径,以下内容将以英文显示:

  • Angular/i18n is an official internationalization tool provided by Angular. It helps developers easily implement multilingual support.

  • To use Angular/i18n, you need to follow these steps:

      1. Add the Angular/i18n package to your project.
      1. Configure the locale files for each supported language.
      1. Use Angular/i18n's annotations to mark translatable strings in your code.

示例代码

Here's a simple example of how to use Angular/i18n annotations in your code:

import { Component } from '@angular/core';

@Component({
  selector: 'app-example',
  template: `
    <h1 i18n="@@exampleTitle">{{ 'Example' | i18n }}</h1>
    <p i18n="@@exampleDescription">{{ 'This is an example component.' | i18n }}</p>
  `
})
export class ExampleComponent {}

相关链接

更多关于 Angular/i18n 的信息,请访问我们的官方文档:Angular/i18n 官方文档

Angular Logo