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

Commit

Permalink
fix(filter): apply notFoundIndicators also for instant translations c…
Browse files Browse the repository at this point in the history
…orrectly

Fixes #866
  • Loading branch information
tspaeth authored and knalli committed Jan 10, 2015
1 parent b61723e commit 5a9f436
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,8 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
if ($translationTable[possibleLangKey]) {
if (typeof $translationTable[possibleLangKey][translationId] !== 'undefined') {
result = determineTranslationInstant(translationId, interpolateParams, interpolationId);
} else if ($notFoundIndicatorLeft || $notFoundIndicatorRight) {
result = applyNotFoundIndicators(translationId);
}
}
if (typeof result !== 'undefined') {
Expand Down
26 changes: 26 additions & 0 deletions test/unit/filter/translate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,30 @@ describe('pascalprecht.translate', function () {
expect($translate('FOO', {}, 'custom')).toEqual('custom interpolation');
}));
});
describe('shall add the prefix and suffix elements', function () {

beforeEach(module('pascalprecht.translate', function ($translateProvider, $provide) {

$translateProvider.translations('en', {
'FOO': 'Have foo'
});

$translateProvider
.preferredLanguage('en')
.translationNotFoundIndicator('-+-+');
}));

var $translate, $filter, $rootScope, $q;
beforeEach(inject(function (_$filter_, _$rootScope_, _$q_) {
$filter = _$filter_;
$rootScope = _$rootScope_;
$q = _$q_;
$translate = $filter('translate');
}));

it('should contain the not found indicators', inject(function () {
expect($translate('FOO')).toEqual('Have foo');
expect($translate('FOO2')).toEqual('-+-+ FOO2 -+-+');
}));
});
});

0 comments on commit 5a9f436

Please sign in to comment.