diff --git a/packages/core/src/js/services/ui-i18n.js b/packages/core/src/js/services/ui-i18n.js
index 17d5aec74d..b9b6183512 100644
--- a/packages/core/src/js/services/ui-i18n.js
+++ b/packages/core/src/js/services/ui-i18n.js
@@ -98,6 +98,11 @@
}
};
+ function getMissingText(path) {
+ $log.warn(i18nConstants.MISSING + path);
+ return '';
+ }
+
var service = {
/**
@@ -174,14 +179,13 @@
getSafeText: function (path, lang) {
var language = lang || service.getCurrentLang(),
trans = langCache.get(language),
- missing = i18nConstants.MISSING + path,
getter = $parse(path);
if (!trans) {
- return missing;
+ return getMissingText(path);
}
- return getter(trans) || missing;
+ return getter(trans) || getMissingText(path);
},
/**
diff --git a/packages/core/test/i18n/directives.spec.js b/packages/core/test/i18n/directives.spec.js
index b650204ad9..7613007570 100644
--- a/packages/core/test/i18n/directives.spec.js
+++ b/packages/core/test/i18n/directives.spec.js
@@ -60,11 +60,11 @@ describe('i18n Directives', function() {
expect(element.find('p').text()).toBe('Search...');
});
- it('should get missing text for missing property', function() {
+ it('should get empty string for missing property', function() {
element = angular.element('
');
recompile();
- expect(element.find('p').text()).toBe('[MISSING]search.bad.text');
+ expect(element.find('p').text()).toBe('');
});
});
@@ -98,15 +98,15 @@ describe('i18n Directives', function() {
expect(element.find('p').text()).toBe('Search...');
});
- it('should get missing text for missing property', function() {
+ it('should get empty string for missing property', function() {
element = angular.element('');
recompile();
- expect(element.find('p').text()).toBe('[MISSING]search.bad.text');
+ expect(element.find('p').text()).toBe('');
$rootScope.$broadcast('$uiI18n');
- expect(element.find('p').text()).toBe('[MISSING]search.bad.text');
+ expect(element.find('p').text()).toBe('');
});
});
@@ -120,11 +120,11 @@ describe('i18n Directives', function() {
expect(element.find('p').text()).toBe('Search...');
});
- it('should get missing text for missing property', function() {
+ it('should get empty string for missing property', function() {
element = angular.element('{{"search.bad.text" | t}}
');
recompile();
- expect(element.find('p').text()).toBe('[MISSING]search.bad.text');
+ expect(element.find('p').text()).toBe('');
});
});
@@ -144,11 +144,11 @@ describe('i18n Directives', function() {
expect(element.find('p').text()).toBe('Search...');
});
- it('should get missing text for missing property', function() {
+ it('should get empty string for missing property', function() {
element = angular.element('{{"search.bad.text" | uiTranslate}}
');
recompile();
- expect(element.find('p').text()).toBe('[MISSING]search.bad.text');
+ expect(element.find('p').text()).toBe('');
});
});
});
diff --git a/packages/core/test/i18n/i18nService.spec.js b/packages/core/test/i18n/i18nService.spec.js
index aac10fa5da..71a18aada4 100644
--- a/packages/core/test/i18n/i18nService.spec.js
+++ b/packages/core/test/i18n/i18nService.spec.js
@@ -1,13 +1,19 @@
describe('i18nService', function () {
- var i18nConstants, i18nService;
+ var $log, i18nConstants, i18nService;
beforeEach(function() {
- module('ui.grid');
+ $log = jasmine.createSpyObj('$log', ['warn']);
+ module('ui.grid', function($provide) {
+ $provide.value('$log', $log)
+ });
inject(function (_i18nConstants_, _i18nService_) {
i18nConstants = _i18nConstants_;
i18nService = _i18nService_;
});
});
+ afterEach(function() {
+ $log.warn.calls.reset();
+ });
describe('i18n service', function() {
it('should default to English', function() {
@@ -77,30 +83,34 @@ describe('i18nService', function () {
it('should get safe text when text is defined', function() {
expect(i18nService.getSafeText('search.placeholder')).toBe('Search...');
});
- it('should get missing text for missing property', function() {
+ it('should get empty string for missing property', function() {
var badText = 'search.bad.text';
- expect(i18nService.getSafeText(badText)).toBe(i18nConstants.MISSING + badText);
+ expect(i18nService.getSafeText(badText)).toBe('');
+ expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + badText);
});
it('should get fallback text when language is missing or nonexistent', function() {
expect(i18nService.getSafeText('search.placeholder', 'valerian')).toBe('Search...');
});
- it('should get missing text when language is missing or nonexistent and there is no fallback', function() {
+ it('should get empty string when language is missing or nonexistent and there is no fallback', function() {
var badText = 'bad.text';
- expect(i18nService.getSafeText(badText, 'valerian')).toBe(i18nConstants.MISSING + badText);
+ expect(i18nService.getSafeText(badText, 'valerian')).toBe('');
+ expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + badText);
});
- it('should get missing text when language is missing or nonexistent and the fallback language is the same', function() {
+ it('should get empty string when language is missing or nonexistent and the fallback language is the same', function() {
var missingProperty = 'search.placeholder';
i18nService.setFallbackLang('valerian');
- expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(i18nConstants.MISSING + missingProperty);
+ expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe('');
+ expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + missingProperty);
});
- it('should get missing text when language is missing or nonexistent and the fallback language is also missing it', function() {
+ it('should get empty string when language is missing or nonexistent and the fallback language is also missing it', function() {
var missingProperty = 'search.placeholder';
i18nService.setFallbackLang('orcish');
- expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(i18nConstants.MISSING + missingProperty);
+ expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe('');
+ expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + missingProperty);
});
});
});