The StaticFilesLoader expects that you store all translations for different languages in separate files on the server. It makes requests like this:
/your/server/i18n/locale-en.json
/your/server/i18n/locale-de.json
/your/server/i18n/locale-fr.json
where /your/server/i18n/locale-
and .json
are prefix and suffix (respectively) which you've passed during configuration.
The UrlLoader expects that you have one "clever" endpoint instead of a bunch of files. It makes requests like this:
/your/server/i18n/locale-endpoint?lang=en
/your/server/i18n/locale-endpoint?lang=de
/your/server/i18n/locale-endpoint?lang=fr
where /your/server/i18n/locale-endpoint
and lang
are url and queryParameter (respectively) which you've passed during configuration. The url is required, but queryParameter may be omitted (defaults to "lang").
You can setup the UrlLoader either like this:
$translateProvider.useUrlLoader('/path/to/your/endpoint', {
queryParameter : 'localeKey'
});
or like this:
$translateProvider.useLoader('$translateUrlLoader', {
url : '/path/to/your/endpoint',
queryParameter : 'localeKey'
});
Both loaders expect to load translation as JSON object. It could look like this:
{
"translationId" : "Translation for this ID",
"anotherTranslationId": "Another translation for another id"
}
You can find more information about different loaders in the official guide.
A source code of the UrlLoader can be found in the angular-translate repository.
Hope, this helps.