mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
feat(react-redux-i18n): definitions (#12052)
* feat(react-redux-i18n): definitions Added definitions for react-redux-i18n https://github.com/zoover/react-redux-i18n * Renamed test file to react-redux-i18n-tests.tsx
This commit is contained in:
committed by
Masahiro Wakame
parent
4a17fd3ae7
commit
988270f5f4
52
react-redux-i18n/react-redux-i18n-tests.tsx
Normal file
52
react-redux-i18n/react-redux-i18n-tests.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
/// <reference path="./react-redux-i18n.d.ts"/>
|
||||
|
||||
import * as React from "react";
|
||||
import * as I18n from "react-redux-i18n";
|
||||
|
||||
class ReactReduxI18nTests_Translate1 extends React.Component<React.Props<{}>, {}>{
|
||||
|
||||
render() {
|
||||
return (
|
||||
<I18n.Translate value="application.title" />
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ReactReduxI18nTests_Translate2 extends React.Component<React.Props<{}>, {}>{
|
||||
|
||||
render() {
|
||||
return (
|
||||
<I18n.Translate value="application.hello" name="Aad" />
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ReactReduxI18nTests_Translate3 extends React.Component<React.Props<{}>, {}>{
|
||||
|
||||
render() {
|
||||
return (
|
||||
<I18n.Localize value="2015-09-03" dateFormat="date.long"/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ReactReduxI18nTests_Translate4 extends React.Component<React.Props<{}>, {}>{
|
||||
|
||||
render() {
|
||||
return (
|
||||
<I18n.Localize value={10/3} options={{style: 'currency', currency: 'EUR', minimumFractionDigits: 2, maximumFractionDigits: 2}} />
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function testI18Helper() {
|
||||
I18n.I18n.t('application.title'); // => returns 'Toffe app met i18n!'
|
||||
I18n.I18n.t('application.name', { name: 'Aad' }); // => returns 'Hallo, Aad!'
|
||||
|
||||
I18n.I18n.l(1385856000000, { dateFormat: 'date.long' }); // => returns '1 december 2013'
|
||||
I18n.I18n.l(Math.PI, { maximumFractionDigits: 2 }); // => returns '3,14'
|
||||
}
|
||||
65
react-redux-i18n/react-redux-i18n.d.ts
vendored
Normal file
65
react-redux-i18n/react-redux-i18n.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// Type definitions for react-redux-i18n
|
||||
// Project: https://github.com/zoover/react-redux-i18n
|
||||
// Definitions by: Clément Devos <https://github.com/clementdevos>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../react/react.d.ts" />
|
||||
///<reference path="../redux/redux.d.ts" />
|
||||
|
||||
declare module 'react-redux-i18n' {
|
||||
import R = __React;
|
||||
import _Redux = Redux;
|
||||
|
||||
/**
|
||||
* Helper methods
|
||||
*/
|
||||
interface I18n {
|
||||
t(code: string, options?: any): string;
|
||||
l(timestamp: number, options?: any): string;
|
||||
}
|
||||
export var I18n : I18n;
|
||||
|
||||
type SubTranslationObject = string | { [key: string]: SubTranslationObject };
|
||||
|
||||
type TranslationObjects = { [lang: string]: SubTranslationObject };
|
||||
|
||||
type I18nState = {
|
||||
translations: TranslationObjects;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
type TranslateProps = {
|
||||
value: string;
|
||||
[prop: string]: string;
|
||||
|
||||
}
|
||||
type LocalizeProps = {
|
||||
value: string | number;
|
||||
dateFormat?: string;
|
||||
options?: Object;
|
||||
}
|
||||
|
||||
/**
|
||||
* React components
|
||||
*/
|
||||
export class Translate extends R.Component<TranslateProps, any>{ }
|
||||
export class Localize extends R.Component<LocalizeProps, any>{ }
|
||||
|
||||
/**
|
||||
* Reducer
|
||||
*/
|
||||
export function i18nReducer(state?: any, options?: any): _Redux.Reducer<I18nState>;
|
||||
|
||||
/**
|
||||
* Reducer init
|
||||
*/
|
||||
export function syncTranslationWithStore(store: _Redux.Store<any>): void;
|
||||
|
||||
/**
|
||||
* Redux Actions
|
||||
*/
|
||||
export function loadTranslations(translationsObject: TranslationObjects): void;
|
||||
|
||||
export function setLocale(locale: string): void;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user