gettextCatalog service

Usage:

angular.module("myApp").controller("MyCtrl", function ($scope, gettextCatalog) {
    // Do things with gettextCatalog
});

Fields

Methods

setCurrentLanguage(lang)

Sets the current language and makes sure that all translations get updated correctly.

getCurrentLanguage()

Returns the current language.

setStrings(language, strings)

Processes an object of string definitions. More details here.

getString(string, scope, context)

Translate a string with the given scope and context. Uses Angular.JS interpolation, so something like this will do what you expect:

var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
// var hello will be "Hallo Ruben!" in Dutch.

The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.

getPlural(n, string, stringPlural, context)

Translate a plural string with the given context.

loadRemote(url)

Load a set of translation strings from a given URL. This should be a JSON catalog generated with grunt-angular-gettext. More details here.

translate directive

See Using the translate directive.

translate filter

See Using the translate filter.