Merge pull request #2834 from panuhorsmalahti/master

Add exists function to i18next
This commit is contained in:
Basarat Ali Syed
2014-09-16 22:58:11 +10:00
2 changed files with 22 additions and 4 deletions
+18 -1
View File
@@ -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"] } },
+4 -3
View File
@@ -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;
}