Translating AngularJS Applications in Context With Angular-Phrase

When developing large AngularJS applications for a wide audience, internationalization of these apps becomes more and more important.

AngularJS is an awesome Javascript framework to build single-page applications with Javascript. We’re huge fans of the framework that was developed and is maintained by the Google team.

When developing large AngularJS applications for a wide audience, internationalization of these apps becomes more and more important to make the user interface accessible for users worldwide.

Handling the underlying i18n processes and files can be tedious and difficult to implement: interpolation, handling pluralization, guessing the correct user locale etc.

Fortunately, the AngularJS developer community is very active and publishes awesome modules on a regular basis. One of the most popular modules might be angular-translate, a full-features AngularJS module that covers almost every aspect of internationalizing apps:

  • Loading i18n locale data
  • Handling pluralization and interpolation
  • Caching translations
  • Guessing the user’s locale
  • and many more

Covering all aspects of angular-translate fills a whole tutorial itself. See the angular-translate tutorial on ng-newsletter for a great introduction to the module.

In-context editing for AngularJS apps

If you’re familiar with the Phrase in-context editor you know what a powerful tool it is to speed up the translation process and boost the content’s quality. Editing translations directly on the page is fast and easy! If you don’t know in-context editing yet, have a look at our demo.

Adding in-context editing capability to your localized AngularJS app is easy with the angular-phrase adapter.

It extends the methods provided by angular-translate and makes every translatable string editable by the Phrase in-context editor.

Install Angular-Phrase

Install Angular-Phrase via Bower:

bower install angular-phrase

(or download it manually from the dist folder)

Build from source

You can also build it directly from source to get the latest and greatest:

grunt build

Add the module

Add angular-phrase module to your existing AngularJS application after loading the angular-translatemodule:

var myApp = angular.module("myApp", ['pascalprecht.translate', 'phrase'])

Configure

Configure the module:

myApp.value("phraseProjectId", "YOUR-PROJECT-ID");
myApp.value("phraseEnabled", true);
myApp.value("phraseDecoratorPrefix", "{{__");
myApp.value("phraseDecoratorSuffix", "__}}");

Javascript snippet

Add the phrase-javascript directive within your application, usually best within the <head>:

<phrase-javascript></phrase-javascript>

If this does not work for you, you can also try to integrate the Javascript snippet manually.

Done

If you have done everything correctly you should be able to start your AngularJS app with the in-context editor and start editing translations super-fast.

Summary

Localizing your existing AngularJS apps with angular-translate can be done easily. It’s a great module that covers everything you need to implement a localized version of your apps.

With just a few extra steps you can add the powerful Phrase in-context editor as well and speed up your localization process. Go ahead, translate your app, and get happier customers worldwide.

Keep exploring

Photo-realistic sheet music featuring developer-style translation code in place of musical notes. The staff lines show snippets like t('auth.signin.button') and JSON structures, combining the aesthetics of musical notation with programming syntax to illustrate the idea of “composable localization.”

Blog post

Localization as code: a composable approach to localization

Why is localization still a manual, disconnected process in a world where everything else is already “as code”? Learn how a composable, developer-friendly approach brings localization into your CI/CD pipeline, with automation, observability, and Git-based workflows built in.

A woman in a light sweater sits in a home office, focused on her laptop, representing a developer or content manager working on WordPress localization tasks in a calm, professional environment.

Blog post

How to build a scalable WordPress i18n workflow

WordPress powers the web, but translating it well takes more than plugins. Discover how to build a scalable localization workflow using gettext, best practices, and the Phrase plugin.

Blog post

Localizing Unity games with the official Phrase plugin

Want to localize your Unity game without the CSV chaos? Discover how the official Phrase Strings Unity plugin simplifies your game’s localization workflow—from string table setup to pulling translations directly into your project. Whether you’re building for German, Serbian, or beyond, this guide shows how to get started fast and localize like a pro.

Blog post

Internationalization beyond code: A developer’s guide to real-world language challenges

Discover how language affects your UI. From text expansion to pluralization, this guide explores key i18n pitfalls and best practices for modern web developers.

A digital artwork featuring the Astro.js logo in bold yellow and purple tones, floating above Earth's horizon with a stunning cosmic nebula in the background. The vibrant space setting symbolizes the global and scalable nature of Astro’s localization capabilities, reinforcing the article’s focus on internationalization in web development.

Blog post

Astro.js localization part 2: dynamic content localization

Learn how to localize your Astro.js website with static and dynamic content translation. Explore Astro’s built-in i18n features and Paraglide for handling UI elements, navigation, and dynamic text seamlessly.