Search code examples
meanjsangular-translate

Angular-translator not working ( useStaticFilesLoader )


I am using Angular-translate (PascalPrecht module) with StaticFilesLoader in mean.js. But getting the error in browser console as ,

http://localhost:1234/app/languages/es.json 404 (Not Found)

and the translation is not working. I tried all the options in other sites but my issue still persists. Can anybody suggest how to set path to json file in mean.js

This is my code

public/module/user/config.js

  $translateProvider.useStaticFilesLoader({
  prefix: 'app/languages/',
  suffix: '.json'
});  

 $translateProvider.preferredLanguage('es');

and i set my json file in app/languages/es.json

{ "TITLE": "Hello", "SUBJECT": "this is it" }


Solution

  • This is difficult to know for sure without seeing your whole app structure. Where is your directory "app" located? If you try to open http://localhost:1234/app/languages/es.json in your browser address bar, does it work? What is the URL for config.js? If it's: http://localhost:1234/module/user/config.js then I believe you just need to move the app/languages tree under 'public'.