Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchchn committed Sep 6, 2017
1 parent 2e83b11 commit d41acd2
Show file tree
Hide file tree
Showing 22 changed files with 950 additions and 1,209 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
dist/
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (c) 2017 AgileBits Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Empty file.
96 changes: 0 additions & 96 deletions dist/es6/extract-strings/extract-strings.js

This file was deleted.

151 changes: 0 additions & 151 deletions dist/es6/i18n.js

This file was deleted.

79 changes: 2 additions & 77 deletions dist/es6/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,2 @@
/// <reference path="../../node_modules/@types/react/index.d.ts" />
/**
* T.js - lightweight localization
* v0.2
*
* T.js defers to standards to do the hard work of localization. The browser Intl API is use to format
* dates and numbers. Messages are provided as functions rather than strings, so they can be compiled at build time.
*
*
* Cobbled together by Mitch Cohen on July 31, 2017
*/
export declare type MFunc = (replacements?: Replacements) => string;
export declare type Compiler = (message: string) => MFunc;
export interface Replacements {
[s: string]: any;
}
export interface Messages {
[s: string]: {
[s: string]: string | MFunc;
};
}
export interface SetupOptions {
messages?: Messages;
locale?: string;
idGenerator?: (message: string) => string;
compiler?: Compiler;
}
export interface PluralOptions {
other: string;
one?: string;
zero?: string;
}
export interface TFunc {
(message: string, replacements?: Replacements, id?: string): string;
lookup?: (id: string, replacements?: Replacements, defaultMessage?: string) => string;
setup?: (options?: SetupOptions) => any;
date?: (value: any, formatName?: string, locale?: string) => string;
number?: (value: any, formatName?: string, locale?: string) => string;
$?: (message: string, replacements?: any, id?: string) => any[];
_i18nInstance?: I18n;
}
export declare type IntlFormat = Intl.DateTimeFormat | Intl.NumberFormat;
export declare type IntlFormatType = (typeof Intl.DateTimeFormat | typeof Intl.NumberFormat);
export declare type IntlFormatOptions = Intl.DateTimeFormatOptions | Intl.NumberFormatOptions;
export declare type CachedFormatter = (locale: string, formatOptions?: IntlFormatOptions) => IntlFormat;
export declare let dateTimeFormatOptions: {
[s: string]: Intl.DateTimeFormatOptions;
};
export declare let numberFormatOptions: {
[s: string]: Intl.NumberFormatOptions;
};
export declare const collationTable: string[];
export declare const defaultLanguage = "en";
export declare const generator: {
plain(message: string): string;
hyphens(message: string): string;
};
export declare function Plural(pluralizeFor: string, options: PluralOptions): string;
export declare function createCachedFormatter(intlFormat: (IntlFormatType)): CachedFormatter;
export declare class I18n {
locale: string;
messages: Messages;
idGenerator: (message: string) => any;
dateFormatter: CachedFormatter;
numberFormatter: CachedFormatter;
compiler: Compiler;
static defaultSetup: SetupOptions;
constructor(options?: SetupOptions);
format(type: string, value: number | Date, formatStyle?: string, locale?: string): any;
getKey(key: string, locale?: string): MFunc | String;
generateId(message: string): any;
lookup(id: string, replacements?: Replacements, defaultMessage?: string): string;
setup(options?: SetupOptions): SetupOptions;
}
export declare function i18nNamespace(): TFunc;
export declare const T: TFunc;
export declare const makeI18n: typeof i18nNamespace;
export { Plural, generator } from "./helpers";
export { default as T, makeT } from "./t-i18n";
Loading

0 comments on commit d41acd2

Please sign in to comment.