#459 passing tests
This commit is contained in:
@@ -14,30 +14,6 @@ test('translate simple key default locale', function () {
|
||||
equal(fmt.t('Add_row'), 'Add row');
|
||||
});
|
||||
|
||||
test('override custom locale', function () {
|
||||
var fmt = I18nMessages('recline', recline.View.translations, 'pl');
|
||||
var oldTranslation = recline.View.translations['pl']['Grid'];
|
||||
|
||||
// set custom strings in external app after including recline script
|
||||
recline.View.translations['pl']['Grid'] = 'Dane';
|
||||
|
||||
equal(fmt.t('Grid'), 'Dane');
|
||||
|
||||
recline.View.translations['pl']['Grid'] = oldTranslation;
|
||||
});
|
||||
|
||||
test('override default locale', function () {
|
||||
var fmt = I18nMessages('recline', recline.View.translations, 'en');
|
||||
var oldTranslation = recline.View.translations['en']['Grid'];
|
||||
|
||||
// set custom strings in external app after including recline script
|
||||
recline.View.translations['en']['Grid'] = 'Data';
|
||||
|
||||
equal(fmt.t('Grid'), 'Data');
|
||||
|
||||
recline.View.translations['en']['Grid'] = oldTranslation;
|
||||
});
|
||||
|
||||
test('fallback to key if translation not present', function () {
|
||||
var fmt = I18nMessages('somelib', Fixture.getTranslations());
|
||||
|
||||
@@ -53,11 +29,6 @@ test('fallback to default message', function () {
|
||||
test('mustache formatter - simple key', function () {
|
||||
var fmt = I18nMessages('somelib', Fixture.getTranslations(), 'pl');
|
||||
|
||||
// test without template rendering
|
||||
var mustacheIntegration = fmt.injectMustache({});
|
||||
equal(mustacheIntegration.t.Grid, 'Tabela')
|
||||
|
||||
// test within template rendering
|
||||
var template = '{{t.Grid}}';
|
||||
var tmplData = {};
|
||||
|
||||
@@ -84,7 +55,7 @@ test('mustache formatter - complex key', function () {
|
||||
test('translate complex key default locale', function () {
|
||||
var fmt = I18nMessages('somelib', Fixture.getTranslations(), 'pl');
|
||||
|
||||
equal(view.t('codeforall', {records: 3}, '<span>{records} records</span>'), '<span>3 records</span>');
|
||||
equal(fmt.t('codeforall', {records: 3}, '<span>{records} records</span>'), '<span>3 records</span>');
|
||||
});
|
||||
|
||||
test('mustache formatter - translate complex key custom locale', function () {
|
||||
@@ -93,7 +64,7 @@ test('mustache formatter - translate complex key custom locale', function () {
|
||||
codeforall: '<span>{records} rekordy</span>'
|
||||
}
|
||||
};
|
||||
var fmt = I18nMessages('somelib', translations, 'pl');
|
||||
var fmt = I18nMessages('somelib2', translations, 'pl');
|
||||
|
||||
equal(fmt.t('codeforall', {records: 3}, '<span>{records} records</span>'), '<span>3 rekordy</span>');
|
||||
});
|
||||
@@ -101,14 +72,14 @@ test('mustache formatter - translate complex key custom locale', function () {
|
||||
test('mustache formatter - translate complex key custom locale custom count', function () {
|
||||
var translations = {
|
||||
pl: {
|
||||
codeforall: {records, plural, ' +
|
||||
codeforall: '{records, plural, ' +
|
||||
'=0 {brak zdjęć}' +
|
||||
'=1 {{records} zdjęcie}' +
|
||||
'few {{records} zdjęcia}' +
|
||||
'other {{records} zdjęć}}'
|
||||
}
|
||||
};
|
||||
var fmt = I18nMessages('somelib', translations, 'pl');
|
||||
var fmt = I18nMessages('somelib3', translations, 'pl');
|
||||
|
||||
equal(fmt.t('codeforall', {records: 0}), 'brak zdjęć');
|
||||
equal(fmt.t('codeforall', {records: 1}), '1 zdjęcie');
|
||||
@@ -131,15 +102,6 @@ test('I18nMessages default locale', function () {
|
||||
equal(fmt.getLocale(), 'en');
|
||||
});
|
||||
|
||||
test('I18nMessages default html:lang default locale resolver', function () {
|
||||
var fmt = I18nMessages('somelib', {});
|
||||
|
||||
|
||||
$('html').attr('lang', 'de');
|
||||
equal(fmt.getLocale(), 'de');
|
||||
$('html').attr('lang', null);
|
||||
});
|
||||
|
||||
test('I18nMessages default locale custom resolver', function () {
|
||||
var localeResolver = function() { return 'fr'; };
|
||||
var fmt = I18nMessages('somelib', {}, localeResolver);
|
||||
@@ -147,7 +109,7 @@ test('I18nMessages default locale custom resolver', function () {
|
||||
equal(fmt.getLocale(), 'fr');
|
||||
});
|
||||
|
||||
test('I18nMessages singletons, function () {
|
||||
test('I18nMessages singletons', function () {
|
||||
var lib1_pl = I18nMessages('lib1', {}, 'pl');
|
||||
var lib2_pl = I18nMessages('lib2', {}, 'pl');
|
||||
var lib1_en = I18nMessages('lib1', {}, 'en');
|
||||
|
||||
Reference in New Issue
Block a user