📅  最后修改于: 2023-12-03 15:29:23.438000             🧑  作者: Mango
Angular is a popular JavaScript framework used for developing web applications. One of its key features is internationalization, or i18n for short, which allows developers to create applications that support multiple languages easily.
Angular's i18n system requires developers to use special syntax in their HTML templates and TypeScript code, marking all translatable content with custom attributes or methods. This is where the Angular Extract i18n tool comes in handy.
The Angular Extract i18n tool, which is a command-line interface (CLI) tool, extracts all translatable content from an Angular project and generates corresponding translation files, ready for translation by human translators or machine translation services.
This article provides an overview of how to use the Angular Extract i18n tool on Shell/Bash.
Before running the Angular Extract i18n tool, you must ensure that you have installed the following software on your system:
The Angular Extract i18n tool can be used with the command:
ng extract-i18n [options]
The following options are available:
--browser-target
or -b
: specifies the target for which the translation files should be generated. This option is required if your application supports more than one target.--i18n-format
: specifies the format of the generated translation files. The default is xlf
.--out-file
: specifies the name of the generated translation file.--verbose
: enables verbose logging.To extract i18n messages for a specific target, run the following command:
ng extract-i18n --browser-target=your-browser-target
This will extract all i18n messages from the specified target and generate a corresponding translation file in the src/locale
directory.
The Angular Extract i18n tool is an essential utility for developers who want to develop multilingual applications using Angular. With this tool, developers can easily extract all the translatable content from an Angular project and generate translation files.
In this article, we provided an introduction to the Angular Extract i18n tool and explained how to use it with the Shell/Bash command line interface. Now that you have learned how to use this tool, you can take your Angular projects to the next level by supporting multiple languages with ease.