more type arguments + header format fix

This commit is contained in:
Ákos Lukács
2015-06-23 11:23:50 +02:00
parent 5ce0dfb57b
commit 7a37cdbfbc
2 changed files with 14 additions and 11 deletions
+7 -6
View File
@@ -12,19 +12,18 @@ module angular_gettext_tests {
//Highlighting untranslated strings
gettextCatalog.debug = true;
// Marking strings in JavaScript code as translatable.
// https://angular-gettext.rocketeer.be/dev-guide/annotate-js/
var gettext = angular_gettext.gettext;
var myString = gettext("Hello");
//Translating directly in JavaScript.
angular.module("myApp").controller("helloController", function (gettextCatalog) {
angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) {
var translated: string = gettextCatalog.getString("Hello");
});
angular.module("myApp").controller("helloController", function (gettextCatalog) {
angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) {
var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds");
});
@@ -43,13 +42,15 @@ module angular_gettext_tests {
});
interface helloControllerScope extends ng.IScope {
switchLanguage: (lang: string) => void;
}
// Lazy-loading languages
// https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/
angular.module("myApp").controller("helloController", function ($scope, gettextCatalog: angular_gettext.gettextCatalog) {
angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular_gettext.gettextCatalog) {
$scope.switchLanguage = function (lang: string) {
gettextCatalog.setCurrentLanguage(lang);
gettextCatalog.loadRemote("/languages/" + lang + ".json");
};
});
}
+7 -5
View File
@@ -1,6 +1,6 @@
// Type definitions for angular-gettext v2.1.0
// Project: https://angular-gettext.rocketeer.be/
// Definitions by: Ákos Lukács https://github.com/AkosLukacs
// Definitions by: Ákos Lukács <https://github.com/AkosLukacs>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
@@ -24,7 +24,9 @@ declare module angular_gettext {
translatedMarkerSuffix: string;
/** An object of loaded translation strings.Shouldn't be used directly. */
strings: {};
/** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated */
/** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated
* @deprecreated
*/
baseLanguage: string;
@@ -33,7 +35,7 @@ declare module angular_gettext {
///////////////
/** Sets the current language and makes sure that all translations get updated correctly. */
setCurrentLanguage(lang: string);
setCurrentLanguage(lang: string): void;
/** Returns the current language. */
getCurrentLanguage(): string;
@@ -43,7 +45,7 @@ declare module angular_gettext {
@param strings A dictionary of strings. The format of this dictionary is:
- Keys: Singular English strings (as defined in the source files)
- Values: Either a single string for signular-only strings or an array of plural forms. */
setStrings(language: string, strings: { [key: string]: string|string[] });
setStrings(language: string, strings: { [key: string]: string|string[] }): void;
/** Get the correct pluralized (but untranslated) string for the value of n. */
getStringForm(string: string, n: number): string;
@@ -59,7 +61,7 @@ declare module angular_gettext {
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
/** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */
loadRemote(url: string);
loadRemote(url: string): ng.IHttpPromise<any>;
}
/** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */