2017-03-16 09:27:55 -05:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2018-01-05 04:42:49 -06:00
|
|
|
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
|
2017-03-16 09:27:55 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
import gettext from 'sources/gettext';
|
|
|
|
import translations from 'translations';
|
2017-03-15 12:10:22 -05:00
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
describe('translate', function () {
|
|
|
|
describe('when there is no translation', function () {
|
|
|
|
it('returns the original string', function () {
|
|
|
|
expect(gettext('something to be translated')).toEqual('something to be translated');
|
2017-03-15 12:10:22 -05:00
|
|
|
});
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
describe('when there are substitutions', function () {
|
|
|
|
it('interpolates a substitution', function () {
|
|
|
|
expect(gettext('translate text for %(person)s', {'person': 'Sarah'})).toEqual('translate text for Sarah');
|
2017-03-15 12:10:22 -05:00
|
|
|
});
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
it('interpolates multiple substitutions', function () {
|
|
|
|
expect(gettext('translate \'%(text)s\' for %(person)s',
|
|
|
|
{
|
|
|
|
'text': 'constitution',
|
|
|
|
'person': 'Sarah',
|
|
|
|
}
|
|
|
|
)).toEqual('translate \'constitution\' for Sarah');
|
2017-03-15 12:10:22 -05:00
|
|
|
});
|
2017-06-12 10:51:54 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when there is a translation', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
translations['something to be translated'] = 'etwas zum uebersetzen';
|
|
|
|
translations['another translation for %(person)s'] = 'eine weitere Uebersetzung fuer %(person)s';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns the translation', function () {
|
|
|
|
expect(gettext('something to be translated')).toEqual('etwas zum uebersetzen');
|
|
|
|
});
|
2017-03-15 12:10:22 -05:00
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
describe('when there is a substitution', function () {
|
|
|
|
it('interpolates the substitution', function () {
|
|
|
|
expect(gettext('another translation for %(person)s', {'person': 'Sarah'}))
|
|
|
|
.toEqual('eine weitere Uebersetzung fuer Sarah');
|
2017-03-15 12:10:22 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|