How to inject and to use angular-translate?

243 views
Skip to first unread message

Maurizio Bellemo

unread,
Sep 23, 2014, 4:48:25 PM9/23/14
to mea...@googlegroups.com
Hi,

I am trying to build a little application and translate it in different language.
I checked the docs of angular-translate, but I do not know where and how to perform the following two actions:

Inject angular-translate module as a dependency into your app: (WHERE SHOULD I DO IT?)

  1. var app = angular.module('myApp', ['pascalprecht.translate']);

Teach you app translations: (WHERE AND HOW?)

  1. app.config(['$translateProvider', function ($translateProvider) {
  2. $translateProvider.translations('en', {
  3. 'TITLE': 'Hello',
  4. 'FOO': 'This is a paragraph'
  5. });
  6.  
  7. $translateProvider.translations('de', {
  8. 'TITLE': 'Hallo',
  9. 'FOO': 'Dies ist ein Paragraph'
  10. });
  11.  
  12. $translateProvider.preferredLanguage('en');
  13. }]);

Alex Suttmiller

unread,
Sep 24, 2014, 9:05:03 AM9/24/14
to
./public/config.js - this is where meanjs includes client dependencies
You can put the second in its own module in ./public/modules. 

Make sure you also include the necessary dependency in your bower.json file, and the JS files in all.js/production.js. Refer to this bug for production.js issues if you attempt to run in production.
Reply all
Reply to author
Forward
0 new messages