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

Commit

Permalink
fix($translate): if translation exists, use the translated string eve…
Browse files Browse the repository at this point in the history
…n if it's empty
  • Loading branch information
Visa Kopu authored and 0x-r4bbit committed Apr 2, 2014
1 parent 2546920 commit eeb8c2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
for (var i = 0, c = possibleLangKeys.length; i < c; i++) {
var possibleLangKey = possibleLangKeys[i];
if ($translationTable[possibleLangKey]) {
if ($translationTable[possibleLangKey][translationId]) {
if (typeof $translationTable[possibleLangKey][translationId] !== 'undefined') {
result = determineTranslationInstant(translationId, interpolateParams, interpolationId);
}
}
Expand All @@ -1482,7 +1482,7 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
}
}

if (!result) {
if (!result && result !== '') {
// Return translation if not found anything.
result = translationId;
if ($missingTranslationHandlerFactory && !pendingLoader) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/service/translate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ describe('pascalprecht.translate', function () {
it('should return translation id if translation id nost exist', function () {
expect($translate.instant('FOO2')).toEqual('FOO2');
});

it('should return empty string if translated string is empty', function () {
expect($translate.instant('BLANK_VALUE')).toEqual('');
});
});

describe('$translate.instant (with fallback)', function () {
Expand Down

0 comments on commit eeb8c2a

Please sign in to comment.