Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Add i18n to your Angular App

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Add i18n to your Angular App


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Hello guys, the other day in my job I had to add multilanguage support to our current Angular App that we are developing, was the first time I had to include this kind of feature to an Angular App, so I had to investigate how to do this implementation and I thought that was amazing share that I learn with you.

First, we need to include the @angular/localize to our angular application.

ng add @angular/localize

We can configure all i18n settings in angular.json

"projects": {
    "angular-localize-example": {
      ................................................
      "i18n": {
           "sourceLocale": "en-US",
           "locales": {
              "es": {
                "translation": "src/locale/messages.es.xlf"
              }
           }
       },
     ................................................

In the "sourceLocale" attribute, we can specify the default language that our application will use, in this case "en-US". In the "locales" attribute we will define the language that our application will support, for example Spanish "es" and the path of the translation file, usually in "src/locale" folder.

The next step is adding the i18n attribute to the HTML where we want to add a translatable text.

<p i18n>Welcome to my app!</p>

Once we have finished placing the attributes where we want. We had to extract the translations with the next command

ng extract-i18n --output-path src/locale

The --output-path parameter specified where will store the generated translation file.

If we open the generated messages.xlf file, we will see something like next

<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en-US" datatype="plaintext" original="ng2.template">
    <body>
      <trans-unit id="856378210155557077" datatype="html">
        <source>Welcome to my app!</source>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/app.component.html</context>
          <context context-type="linenumber">1</context>
        </context-group>
      </trans-unit>
    </body>
  </file>
</xliff>

Now we can copy the file and renamed it like we indicated in angular.json. For the Spanish translation will be messages.es.xlf and edit the text with the translation.

<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="es" datatype="plaintext" original="ng2.template">
    <body>
      <trans-unit id="856378210155557077" datatype="html">
        <source>ยกBienvenidos a mi APP!</source>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/app.component.html</context>
          <context context-type="linenumber">1</context>
        </context-group>
      </trans-unit>
    </body>
  </file>
</xliff>

When we will have all ready we can build our application, but with one new parameter

ng build --localize 

This will generate the build app but separated in the languages that our application support.

...



๐Ÿ“Œ Add i18n to your Angular App


๐Ÿ“ˆ 49.11 Punkte

๐Ÿ“Œ Medium CVE-2020-7791: I18n project I18N


๐Ÿ“ˆ 44.75 Punkte

๐Ÿ“Œ CVE-2020-36627 | Macaron i18n prior 0.5.0 i18n.go redirect


๐Ÿ“ˆ 44.75 Punkte

๐Ÿ“Œ How to upgrade your Angular web project from Angular V13 to Angular V17


๐Ÿ“ˆ 41.84 Punkte

๐Ÿ“Œ CVE-2023-26116 | angular angular.copy redos (SNYK-JS-ANGULAR-3373044)


๐Ÿ“ˆ 38.36 Punkte

๐Ÿ“Œ i18n-node-angular up to 1.3.x on Node.js REST API Endpoint denial of service


๐Ÿ“ˆ 35.16 Punkte

๐Ÿ“Œ i18n-node-angular bis 1.3.x auf Node.js REST API Endpoint Denial of Service


๐Ÿ“ˆ 35.16 Punkte

๐Ÿ“Œ Translate your App's Notification content to different languages using i18n.


๐Ÿ“ˆ 28.92 Punkte

๐Ÿ“Œ Accelerate Angular App Development with create-angular-auth-nav


๐Ÿ“ˆ 28.63 Punkte

๐Ÿ“Œ ANGULAR (FULL APP) WITH ANGULAR MATERIAL, ANGULARFIRE & NGRX


๐Ÿ“ˆ 28.63 Punkte

๐Ÿ“Œ Top 10 Things to Add to Your Angular App Coding: A Recipe for Programmer Success


๐Ÿ“ˆ 26.73 Punkte

๐Ÿ“Œ Angular 5.1 zusammen mit Angular Material 5.0.0 erschienen


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ ANGULAR 6 (FORMERLY ANGULAR 2) โ€“ THE COMPLETE GUIDE


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ 7 steps to Angular Material Dialog instead of Angular Component


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Building a Dynamic Serverless Photo Blog with Angular & Google Sheets - 1: Solving Angular Router Navigation Issues


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Google's New Angular 2.0 Isn't Compatible With Angular 1


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ CVE-2023-26117 | angular redos (SNYK-JS-ANGULAR-3373045)


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ CVE-2023-26118 | angular redos (SNYK-JS-ANGULAR-3373046)


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Updates from the Angular Team and new Angular 17 features!


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Google's New Angular 2.0 Isn't Compatible With Angular 1


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ How to Run Angular Apps Using Angular CLI and PM2


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Angular 17 Encrypting Decrypting Data with CryptoJs | Angular 17 Tutorial | React


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Episode 24/13: Native Signals, Details on Angular/Wiz, Alan Agius on the Angular CLI


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Angular Addicts #24: Angular 17.3, Signals and unit testing best practices, Storybook 8 & more


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Angular Universal is the Problem, not Angular


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Unveiling Angular 17 - The Angular Renaissance


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Angular is Much Better, But is Angular Universal?


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Implementing Angular Server-Side Rendering (SSR) AKA Angular Universal


๐Ÿ“ˆ 25.57 Punkte

๐Ÿ“Œ Internationalizing and Localizing a React App: i18n Made Easy


๐Ÿ“ˆ 25.43 Punkte

๐Ÿ“Œ i18n with Next.js 13 and app directory


๐Ÿ“ˆ 25.43 Punkte

๐Ÿ“Œ ๐Ÿ๏ธ i18n translations in Next.js 13's app-dir for server/client components ๐ŸŒŠ


๐Ÿ“ˆ 25.43 Punkte

๐Ÿ“Œ Implementing Internationalization (i18n) in Next.js 14 using App Router


๐Ÿ“ˆ 25.43 Punkte

๐Ÿ“Œ Next.js: Internationalisation (i18n) for the `app directory`


๐Ÿ“ˆ 25.43 Punkte

๐Ÿ“Œ International Components for Unicode up to 59.1 i18n/zonemeta.cpp String privilege escalation


๐Ÿ“ˆ 22.38 Punkte

๐Ÿ“Œ Oracle Java SE 6u171/7u161/8u152/9.0.1 I18n privilege escalation


๐Ÿ“ˆ 22.38 Punkte











matomo