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

Commit

Permalink
fix($translate): checks modification
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit committed May 31, 2014
1 parent 1c265c7 commit b91e4de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,11 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
*/
$translate.instant = function (translationId, interpolateParams, interpolationId) {

// Detect undefined and null values to shorten the execution and prevent exceptions
if (translationId === null || angular.isUndefined(translationId)) {
return translationId;
}

// Duck detection: If the first argument is an array, a bunch of translations was requested.
// The result is an object.
if (angular.isArray(translationId)) {
Expand All @@ -1536,7 +1541,8 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
return results;
}

if (typeof translationId === 'undefined' || translationId === '') {
// We discarded unacceptable values. So we just need to verify if translationId is empty String
if (angular.isString(translationId) && translationId.length < 1) {
return translationId;
}

Expand Down

0 comments on commit b91e4de

Please sign in to comment.