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

Null translations #665

Closed
jandudulski opened this issue Aug 6, 2014 · 6 comments
Closed

Null translations #665

jandudulski opened this issue Aug 6, 2014 · 6 comments

Comments

@jandudulski
Copy link

Can we support null values in translations? For know:

  var translationMock = {
    'EXISTING_TRANSLATION_ID': 'foo',
    'BLANK_VALUE': '',
    'TRANSLATION_ID': 'Lorem Ipsum {{value}}',
    'TRANSLATION_ID_2': 'Lorem Ipsum {{value}} + {{value}}',
    'TRANSLATION_ID_3': 'Lorem Ipsum {{value + value}}',
    'NULL_TRANSLATION': null,
    'DOCUMENT': {
      'HEADER': {
        'TITLE': 'Header'
      },
      'SUBHEADER': {
        'TITLE': '2. Header'
      }
    }
  };

  describe('$translate', function () {
    it('should translate null values', function () {
      var deferred = $q.defer(),
          promise = deferred.promise,
          value;

      promise.then(function (translation) {
        value = translation;
      });

      $q.all([
        $translate("NULL_TRANSLATION")
      ]).then(function (translations) {
        deferred.resolve(translations);
      });

      $rootScope.$digest();
      expect(value[0]).toEqual('');
    });
  });
Chrome 36.0.1985 (Linux) pascalprecht.translate $translate should translate null values FAILED
        TypeError: Cannot read property 'substr' of null
            at determineTranslation (/home/yanoo/Work/angular-translate/src/service/translate.js:1134:26)
            at $translate (/home/yanoo/Work/angular-translate/src/service/translate.js:781:11)
            at null.<anonymous> (/home/yanoo/Work/angular-translate/test/unit/service/translate.spec.js:277:9)
Chrome 36.0.1985 (Linux): Executed 251 of 251 (1 FAILED) (1.195 secs / 0.877 secs)
@tspaeth
Copy link
Member

tspaeth commented Aug 6, 2014

Just for relationship in between tickets: This is somehow related to #468 even though targeting another issue and area of angular-translate.

@0x-r4bbit
Copy link
Member

@jandudulski I don't really see a reason why we wanna do that. Make it an empty string instead. Or leave that translation id off.

@jandudulski
Copy link
Author

What if you don't have an impact on the translation source?

@0x-r4bbit
Copy link
Member

@jandudulski well, that's your particular use case, but we can't change angular-translate on all ends to fit to all specific use cases. We have to keep things generic and IMO it's not very common to provide translations with a null value. However, the change wouldn't be that big, so if you want to you can send a patch.

@jandudulski
Copy link
Author

👌

@knalli
Copy link
Member

knalli commented Sep 11, 2014

#706 would be a solution if the source of translation cannot be changed server side.

Will close this.

@knalli knalli closed this as completed Sep 11, 2014
GuyMograbi added a commit to GuyMograbi/angular-translate that referenced this issue Dec 13, 2016
null translation treated as if does not exist

fixes angular-translate#665
GuyMograbi added a commit to GuyMograbi/angular-translate that referenced this issue Dec 19, 2016
null translation treated as if does not exist

fixes angular-translate#665
GuyMograbi added a commit to GuyMograbi/angular-translate that referenced this issue Dec 19, 2016
null translation treated as if does not exist

fixes angular-translate#665
knalli pushed a commit that referenced this issue Jan 1, 2017
null translation treated as if does not exist

Fixes #665
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