DefinitelyTyped/types/gettext.js/gettext.js-tests.ts
Krisztián Balla 17e6fe2e0f Updated gettext.js type definition (#38605)
* Update index.d.ts

Member "locale" of interface "JsonDataHeader" was renamed to "language".

* Update gettext.js-tests.ts

Updated test according to type definition changes.

* Updated version number to 0.8
2019-09-26 12:06:20 -07:00

22 lines
499 B
TypeScript

import * as Gettext from 'gettext.js';
const json: Gettext.JsonData = {
"": {
language: "fr",
"plural-forms": "nplurals=2; plural=n>1;"
},
Welcome: "Bienvenue",
"There is %1 apple": [
"Il y a %1 pomme",
"Il y a %1 pommes"
]
};
const instance: Gettext.Gettext = Gettext.i18n();
instance.loadJSON(json, 'messages');
instance.setLocale('fr');
if (instance.ngettext('There is %1 apple', 'There are %1 apples', 0) === 'Il y a %1 pomme') {
throw new Error('Failed test');
}