Using angualr-translate with requirejs. Want to create separate files for each language (contains translate keys), for the time it is all in app.js.
Example- app.js
define(['angularAMD', 'ngRoute','pascalprecht.translate'], function (angularAMD) {
var app = angular.module('app', ['ngRoute','pascalprecht.translate']);
app.config(['$routeProvider','$translateProvider', function($routeProvider,$translateProvider){
/* *************** routes *************** */
//...........
/* *************** routes *************** */
/* angular translate */
$translateProvider.translations('en', {
add_user: 'Add User',
first_name:'First Name',
last_name:'Last Name',
//.....
//IMPORTANT: more than 1000 translate keys...
//.....
});
$translateProvider.translations('de', {
add_user: 'Benutzer hinzufügen',
first_name:'Vorname',
last_name:'Last Name',
//.....
//IMPORTANT: more than 1000 translate keys...
//.....
});
// Bootstrap Angular when DOM is ready
return angularAMD.bootstrap(app);
});
For case you want to use js instead of JSON.
this is an modified example in the preference link of asynchronus-loading in the end of the answer (section
Using custom loader service
)OLD ANSWER
angular-translate supports on-demand load for translation files. You don't need to use requireJS in this case.
Currenly this is my code in
app.config()
all you need to do is setup url like below
{your_host}/something-translate?lang={language_key}
In my case, the server real url is like.
localhost/translate?lang=en
localhost/translate?lang=fr
localhost/translate?lang=es
...
Then in controller:
Preference link:
https://github.com/angular-translate/angular-translate/wiki/Asynchronous-loading#registering-asynchronous-loaders
https://github.com/angular-translate/angular-translate/wiki/Extensions