mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-07 06:28:26 +08:00
rename module from angular_gettext to angular.gettext + some whitespace cleanup
This commit is contained in:
@@ -1,39 +1,44 @@
|
||||
/// <reference path="angular-gettext.d.ts" />
|
||||
|
||||
module angular_gettext_tests {
|
||||
var gettextCatalog: angular_gettext.gettextCatalog;
|
||||
|
||||
|
||||
|
||||
// Configuring angular-gettext
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/configure/
|
||||
//Setting the language
|
||||
gettextCatalog.setCurrentLanguage('nl');
|
||||
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
gettextCatalog.setCurrentLanguage('nl');
|
||||
});
|
||||
|
||||
//Highlighting untranslated strings
|
||||
gettextCatalog.debug = true;
|
||||
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
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");
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/annotate-js/
|
||||
angular.module("myApp").controller("helloController", function (gettext: angular.gettext.gettextFunction) {
|
||||
var myString = gettext("Hello");
|
||||
});
|
||||
|
||||
//Translating directly in JavaScript.
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.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_gettext.gettextCatalog) {
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds");
|
||||
});
|
||||
|
||||
var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" });
|
||||
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" });
|
||||
});
|
||||
|
||||
// Setting strings manually
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
|
||||
|
||||
angular.module("myApp").run(function (gettextCatalog: angular_gettext.gettextCatalog) {
|
||||
angular.module("myApp").run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
// Load the strings automatically during initialization.
|
||||
gettextCatalog.setStrings("nl", {
|
||||
"Hello": "Hallo",
|
||||
@@ -47,7 +52,7 @@ module angular_gettext_tests {
|
||||
}
|
||||
// Lazy-loading languages
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/
|
||||
angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, 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");
|
||||
|
||||
23
angular-gettext/angular-gettext.d.ts
vendored
23
angular-gettext/angular-gettext.d.ts
vendored
@@ -5,13 +5,13 @@
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular_gettext {
|
||||
declare module angular.gettext {
|
||||
interface gettextCatalog {
|
||||
|
||||
|
||||
//////////////
|
||||
/// Fields ///
|
||||
//////////////
|
||||
|
||||
|
||||
/** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */
|
||||
debug: boolean;
|
||||
/** (default: [MISSING]:): Custom prefix for untranslated strings. */
|
||||
@@ -33,7 +33,7 @@ declare module angular_gettext {
|
||||
///////////////
|
||||
/// Methods ///
|
||||
///////////////
|
||||
|
||||
|
||||
/** Sets the current language and makes sure that all translations get updated correctly. */
|
||||
setCurrentLanguage(lang: string): void;
|
||||
|
||||
@@ -41,10 +41,11 @@ declare module angular_gettext {
|
||||
getCurrentLanguage(): string;
|
||||
|
||||
/** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
|
||||
@param language A language code.
|
||||
@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. */
|
||||
* @param language A language code.
|
||||
* @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[] }): void;
|
||||
|
||||
/** Get the correct pluralized (but untranslated) string for the value of n. */
|
||||
@@ -56,7 +57,7 @@ declare module angular_gettext {
|
||||
* The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
*/
|
||||
getString(string: string, context?: any): string;
|
||||
|
||||
|
||||
/** Translate a plural string with the given context. */
|
||||
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
|
||||
|
||||
@@ -65,6 +66,8 @@ declare module angular_gettext {
|
||||
}
|
||||
|
||||
/** 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 */
|
||||
function gettext(dummyString: string): string;
|
||||
interface gettextFunction {
|
||||
(dummyString: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user