You can set translated strings by injecting the gettextCatalog
and using the setStrings
method.
As an example, you may have the following code in your application:
angular.module("myApp").run(function (gettextCatalog) {
// Load the strings automatically during initialization.
gettextCatalog.setStrings("nl", {
"Hello": "Hallo",
"One boat": ["Een boot", "{{$count}} boats"]
});
});
The setStrings
method accepts two parameters:
language
: A language code.strings
: A dictionary of strings. The format of this dictionary is:
Converting translated .po
files into angular-compatible JavaScript files can be done automatically using the grunt-angular-gettext
module (instructions on how to do this).