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

Sanitation strategy sce fails with fallback language #1618

Closed
MarijnMensinga opened this issue Oct 17, 2016 · 7 comments
Closed

Sanitation strategy sce fails with fallback language #1618

MarijnMensinga opened this issue Oct 17, 2016 · 7 comments
Labels
Milestone

Comments

@MarijnMensinga
Copy link

MarijnMensinga commented Oct 17, 2016

Sanitation strategy sce fails with fallback language

When using a fallback language in conjuction with the sanitation strategy sce a type error is thrown when the string to translate is only available in the fallback language file.

Demo: https://plnkr.co/edit/iWdsq62cnGAY3mdN3aTM?p=preview

The fallbackTranslationInstant function expects a string as result but it gets a TrustedValueHolderType object.

typeError: result.substr is not a function
    at getFallbackTranslationInstant (angular-translate.js:1791)
    at resolveForFallbackLanguageInstant (angular-translate.js:1893)
    at fallbackTranslationInstant (angular-translate.js:1924)
    at determineTranslationInstant (angular-translate.js:2019)
    at Function.$translate.instant (angular-translate.js:2551)
    at translateFilter (angular-translate.js:3620)
    at fn (eval at compile (angular.js:14817), <anonymous>:4:97)
    at oneTimeInterceptedExpression (angular.js:16046)
    at oneTimeWatch (angular.js:15984)
    at Scope.$digest (angular.js:17515)

Your environment

  • version of angular-translate: 2.12.1
  • version of angular: 1.5.8
  • which browser and its version: Chrome 53.0.2785.143 m

Steps to reproduce

  • Two languages
  • Set one langauge as fallback for another
  • Set sanitation strategy to sce
  • Translate a string via a filter

Demo: https://plnkr.co/edit/iWdsq62cnGAY3mdN3aTM?p=preview

Expected behaviour

Everything should be nicely translated

Actual behaviour

TypeError: TrustedValueHolderType object instead of expected string

@MarijnMensinga MarijnMensinga changed the title Sanitisation strategy sce fails with fallback language Sanitation strategy sce fails with fallback language Oct 17, 2016
@knalli
Copy link
Member

knalli commented Oct 17, 2016

Hm, did you have missed saving something in the demo? I guess, at least there is one missing file (angular-sanitize).

@MarijnMensinga
Copy link
Author

Sorry the translation had to be done via filters in order to get the error, I updated the plnkr:
https://plnkr.co/edit/iWdsq62cnGAY3mdN3aTM?p=preview

@knalli
Copy link
Member

knalli commented Oct 18, 2016

Ok, demo working!

Well, looks like sce does not working together with the linking feature (string based).

@MarijnMensinga
Copy link
Author

@knalli are you planning on creating a fix for this? If so, when will it be released you think?

@knalli
Copy link
Member

knalli commented Oct 25, 2016

@MarijnMensinga It will take some days. If you can make a PR fixing the issue, it will faster.

@knalli knalli added this to the 2.12.2 milestone Oct 25, 2016
@knalli knalli added the bug label Oct 25, 2016
@MarijnMensinga
Copy link
Author

I've created a PR #1630
This fixes my problems.. I'm not 100% sure this is enough for a permanent fix in the entire library?

knalli added a commit that referenced this issue Oct 30, 2016
…ectly

Although we have to reconsider the result type of this, this will fix sce+linking.

Fixes #1618
Replaces #1630
@knalli knalli closed this as completed Oct 30, 2016
@knalli
Copy link
Member

knalli commented Oct 30, 2016

Fix: 1ede55e

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

No branches or pull requests

2 participants