@cloudflare/intl-core
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="1.0.3"></a> | ||
## [1.0.3](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/intl-core@1.0.2...@cloudflare/intl-core@1.0.3) (2018-09-27) | ||
**Note:** Version bump only for package @cloudflare/intl-core | ||
<a name="1.0.2"></a> | ||
@@ -8,0 +16,0 @@ ## [1.0.2](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/intl-core@1.0.1...@cloudflare/intl-core@1.0.2) (2018-09-21) |
import Translator from './Translator'; | ||
import makeLoadPhrases from './makeLoadPhrases'; | ||
import { ESupportedLocales } from './types'; | ||
export { ESupportedLocales, Translator }; | ||
export { ESupportedLocales, Translator, makeLoadPhrases }; |
@@ -5,4 +5,2 @@ export var ESupportedLocales; | ||
ESupportedLocales["en_US"] = "en-US"; | ||
ESupportedLocales["de_DE"] = "de-DE"; | ||
ESupportedLocales["pseudoLoc"] = "pseudoLoc"; | ||
})(ESupportedLocales || (ESupportedLocales = {})); |
@@ -12,2 +12,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "makeLoadPhrases", { | ||
enumerable: true, | ||
get: function get() { | ||
return _makeLoadPhrases.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ESupportedLocales", { | ||
@@ -22,4 +28,6 @@ enumerable: true, | ||
var _makeLoadPhrases = _interopRequireDefault(require("./makeLoadPhrases")); | ||
var _types = require("./types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -12,4 +12,2 @@ "use strict"; | ||
ESupportedLocales["en_US"] = "en-US"; | ||
ESupportedLocales["de_DE"] = "de-DE"; | ||
ESupportedLocales["pseudoLoc"] = "pseudoLoc"; | ||
})(ESupportedLocales || (exports.ESupportedLocales = ESupportedLocales = {})); |
{ | ||
"name": "@cloudflare/intl-core", | ||
"description": "", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"types": "./src", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -42,1 +42,21 @@ # intl-core | ||
``` | ||
## makeLoadPhrases | ||
This is a function which takes an object mapping each `locale` to a function | ||
returning a Promise which resolves to the catalog of phrases for that `locale`. | ||
The main usecase for this is to provide a way to asynchronously load phrases | ||
based on `locale`. You can include an `index.ts` file inside your `locale` | ||
directory with the following content: | ||
```jsx | ||
import { makeLoadPhrases, ESupportedLocales } from '@cloudflare/intl-core'; | ||
const loadPhrases = makeLoadPhrases({ | ||
[ESupportedLocales.en_US]: () => import('./en-US/phrases.json') | ||
//...other locales | ||
}); | ||
export default loadPhrases; | ||
``` |
import Translator from './Translator'; | ||
import makeLoadPhrases from './makeLoadPhrases'; | ||
@@ -12,2 +13,2 @@ import { | ||
export { ESupportedLocales, Translator }; | ||
export { ESupportedLocales, Translator, makeLoadPhrases }; |
export type TLoadPhrases = (language: ESupportedLocales) => Promise<IPhrases>; | ||
export enum ESupportedLocales { | ||
en_US = 'en-US', | ||
de_DE = 'de-DE', | ||
pseudoLoc = 'pseudoLoc' | ||
en_US = 'en-US' | ||
} | ||
@@ -7,0 +5,0 @@ export type IPhrases = { |
21603
15
557
62