Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Failing to load multiple files using static loader , using { "file" : #923

Closed
aykutyararbas opened this issue Feb 11, 2015 · 5 comments
Closed
Milestone

Comments

@aykutyararbas
Copy link

//given
var options= {
            "files" :  [{
                prefix: 'i18n/gen-',
                suffix: '.json'
            }, {
                prefix: 'i18n/gen-aykut-',
                suffix: '.json'
            }]
    };
//when
$translateProvider.useStaticFilesLoader(genevaOptions);

//Then
Either gen-en.json or gen-aykut-en.json loaded


//Modifying the load function helped load multiple files 

  $http(angular.extend({
        url: [
          file.prefix,
          file.key,
          file.suffix
        ].join(''),
        method: 'GET',
        params: ''
      }, options.$http)).success(function (data) {
        deferred.resolve(data);
      }).error(function (data) {
        deferred.reject(file.key);
      });

//You can check within plunkr
http://plnkr.co/edit/UnWwcifNEy0AQKW0yPgW?p=preview

Thanks and regards

Aykut Yararbas~

@tspaeth
Copy link
Member

tspaeth commented Feb 12, 2015

The plnkr isn't working correctly at all.

But anyway - the options for the standard static files loader are currently only able to take an option input object as defined in https://github.com/angular-translate/angular-translate/blob/master/src/service/loader-static-files.js

@param {object} options Options object, which gets prefix, suffix and key.

and not an Array of Objects. So if you need a totally different approach - yes you have to write a custom loader / parser.

@aykutyararbas
Copy link
Author

Thanks
Aykut~

On Feb 11, 2015, at 11:31 PM, Thorsten notifications@github.com wrote:

The plnkr isn't working correctly at all.

But anyway - the options for the standard static files loader are currently only able to take an option input object as defined in https://github.com/angular-translate/angular-translate/blob/master/src/service/loader-static-files.js

@param {object} options Options object, which gets prefix, suffix and key.
and not an Array of Objects. So if you need a totally different approach - yes you have to write a custom loader / parser.


Reply to this email directly or view it on GitHub.

@janhmueller
Copy link

Actually, Aykut is correct. You should be able to pass a files array to the loader. Its both in the docs "Alternatively, if you have multiple translation files in distinct locations, you may instead supply an array of files to the loader" + code example and in the code, if you look a bit closer. Aykut's changes seem to fix it.
Best, Jan

knalli pushed a commit to knalli/angular-translate that referenced this issue Mar 1, 2015
knalli added a commit to knalli/angular-translate that referenced this issue Mar 1, 2015
@knalli
Copy link
Member

knalli commented Mar 1, 2015

There is a bug in the processing.

@knalli knalli added this to the 2.7.1 milestone Mar 1, 2015
@knalli knalli modified the milestones: 2.6.1, 2.7.1 Mar 1, 2015
@knalli knalli closed this as completed Mar 1, 2015
@knalli
Copy link
Member

knalli commented Mar 1, 2015

Fixed in latest 2.6.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants