This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Error when trying too translate a falsy value with translate filter #1511
Comments
It looks like the filter is missing a "is string" condition. |
@4kochi I have add some tests.. but they are not failing. What I'm missing here? |
Ok. Thanks. I will have a look. |
Seems to be a problem with angular 1.5.x. The command |
https://travis-ci.org/angular-translate/angular-translate/builds/140397869 Yeah, yesterday I have thought it was only temporarily. Looks like there has been changed something. |
knalli
added a commit
that referenced
this issue
Jul 17, 2016
Since AngularJS 1.5, the input values (i.e. of a filter) will used 'as is' which means numbers (as translation ids) will not be transformed to strings anymore. This generates unexpected errors. Because this fix, the result is that explicit typed number values will be return (transformed as a string). ``` // before and < AJS 1.5 $filter('translate)(0) === 0 // after and < AJS 1.5 $filter('translate)(0) === '0' // before and AJS 1.5+ $filter('translate)(0) exception // after and AJS 1.5+ $filter('translate)(0) === '0' ``` Fixes #1511
Got it. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject of the issue
When using a falsy JavaScript value the translation filter does not work and raises an exception. It works with the translate directive.
Our use case are validation messages with ng-message
The corresponding translation key looks like this:
"SERVER_VALIDATION_MINIMUM": "Wert muß größer/gleich {{expected}} sein"
Your environment
2.11.0
1.5.5
Steps to reproduce
Does not work:
<p>{{ 0 | translate }}</p>
Works:
<p translate>{{ 0 }}</p>
Expected behavior
The value should be translated. Or at least returned as is if there is no translation key.
Actual behavior
Exception in the console:
Error: text.replace is not a function. (In 'text.replace(escapedStartRegexp, startSymbol)', 'text.replace' is undefined)
The text was updated successfully, but these errors were encountered: