mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add exists function to i18next
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/// <reference path="i18next.d.ts" />
|
||||
|
||||
declare function done(): void;
|
||||
|
||||
|
||||
describe('i18next', function () {
|
||||
|
||||
var i18n = $.i18n
|
||||
@@ -685,6 +685,23 @@ describe('i18next', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('exists functionality', function () {
|
||||
var resStore = {
|
||||
dev: { translation: { empty: '' } },
|
||||
en: { translation: {} },
|
||||
'en-US': { translation: {} }
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
i18n.init($.extend(opts, { resStore: resStore }),
|
||||
function (t) { done(); });
|
||||
});
|
||||
|
||||
it('it should be able to test if a key exists', function () {
|
||||
expect(i18n.exists('empty')).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resource string as array', function () {
|
||||
var resStore = {
|
||||
dev: { translation: { testarray: ["title", "text"] } },
|
||||
|
||||
Vendored
+4
-3
@@ -109,6 +109,7 @@ interface I18nextStatic {
|
||||
};
|
||||
t(key: string, options?: any): string;
|
||||
translate(key: string, options?: any): string;
|
||||
exists(key: string, options?: any): boolean;
|
||||
}
|
||||
|
||||
// jQuery extensions
|
||||
@@ -118,9 +119,9 @@ interface JQueryStatic {
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
/* Note: options are same options as used by the translate function. Alternatively by
|
||||
setting init option or translation option 'useDataAttrOptions = true' the Options
|
||||
for translation will be read and cached in the elements data-i18n-options attribute.
|
||||
/* Note: options are same options as used by the translate function. Alternatively by
|
||||
setting init option or translation option 'useDataAttrOptions = true' the Options
|
||||
for translation will be read and cached in the elements data-i18n-options attribute.
|
||||
*/
|
||||
i18n: (options?: I18nextOptions) => void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user