Book Image

Learning Aurelia

By : Manuel Guilbault
Book Image

Learning Aurelia

By: Manuel Guilbault

Overview of this book

<p>Aurelia is one of the most promising new JavaScript frameworks for mobile, desktop, and web, which makes developing powerful, modern web applications a straightforward task. Its power lies in its simplicity and clear workflow that enables developers to build next-generations apps for the web with ease.</p> <p>From initial structuring to full deployment, this book will serve as a step-by-step guide to develop a modern web application from scratch with the Aurelia framework. In addition to including a comprehensive coverage of various Aurelia framework features, this book will also show you how to utilize these features in the real world to develop a professional single-page web application. You’ll see how to make the most out of Aurelia by understanding the Aurelia workflow and then applying it in real-world development tasks. By the end of the book, you will have learned to develop a clean and maintainable application in Aurelia from scratch.</p>
Table of Contents (20 chapters)
Learning Aurelia
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Translating


The aurelia-i18n library offers many different ways to translate texts. In this section, we will see what our options are.

Using attributes

The simplest way to translate text in a template is to use the translation attribute, named t. Let's illustrate this by translating our Not Found page.

We will start by moving the texts to the translation files:

locales/en/translation.js

{ 
  "404": { 
    "explanation": "The page cannot be found.", 
    "title": "Something is broken..." 
  } 
} 

locales/fr/translation.js

{ 
  "404": { 
    "explanation": "La page est introuvable.", 
    "title": "Quelque-chose ne fonctionne pas..." 
  } 
} 

As you can see, with translations being JSON structures, we can use nested keys without any problem.

To statically display a translated text inside an element, you just need to add the t attribute to the element and set its value to the path of the translation key:

src/not-found.html

<template>...