@allthings/cdn-intl-provider
Advanced tools
Comparing version 2.0.1 to 2.0.2
import { Component } from 'react'; | ||
import { IntlConfig } from 'react-intl'; | ||
import 'cross-fetch/polyfill'; | ||
export declare const loadLanguage: (resourcePath: string, project: string, variation: string, locale: string, stage: string) => Promise<object>; | ||
export declare const loadLanguage: (resourcePath: string, project: string, variation: string, locale: string, stage: string) => Promise<Record<string, string> | Record<string, import("intl-messageformat-parser").MessageFormatElement[]>>; | ||
declare type Messages = IntlConfig['messages']; | ||
interface IBasicCDNIntlProviderProps { | ||
@@ -10,3 +12,3 @@ resourcePath: string; | ||
onDone?: () => void; | ||
messages?: object; | ||
messages?: Messages; | ||
variation?: string; | ||
@@ -19,5 +21,5 @@ } | ||
}; | ||
declare type ICDNIntlProviderProps = IBasicCDNIntlProviderProps & typeof defaultProps; | ||
export declare type ICDNIntlProviderProps = IBasicCDNIntlProviderProps & typeof defaultProps; | ||
interface IState { | ||
messages?: object; | ||
messages?: Messages; | ||
} | ||
@@ -24,0 +26,0 @@ export default class CDNIntlProvider extends Component<ICDNIntlProviderProps, IState> { |
@@ -16,6 +16,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -58,3 +59,2 @@ }); | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -64,3 +64,3 @@ var react_1 = __importStar(require("react")); | ||
require("cross-fetch/polyfill"); | ||
exports.loadLanguage = function (resourcePath, project, variation, locale, stage) { return __awaiter(_this, void 0, void 0, function () { | ||
exports.loadLanguage = function (resourcePath, project, variation, locale, stage) { return __awaiter(void 0, void 0, void 0, function () { | ||
var countryCode, translations; | ||
@@ -67,0 +67,0 @@ return __generator(this, function (_a) { |
import { Component } from 'react'; | ||
import { IntlConfig } from 'react-intl'; | ||
import 'cross-fetch/polyfill'; | ||
export declare const loadLanguage: (resourcePath: string, project: string, variation: string, locale: string, stage: string) => Promise<object>; | ||
export declare const loadLanguage: (resourcePath: string, project: string, variation: string, locale: string, stage: string) => Promise<Record<string, string> | Record<string, import("intl-messageformat-parser").MessageFormatElement[]>>; | ||
declare type Messages = IntlConfig['messages']; | ||
interface IBasicCDNIntlProviderProps { | ||
@@ -10,3 +12,3 @@ resourcePath: string; | ||
onDone?: () => void; | ||
messages?: object; | ||
messages?: Messages; | ||
variation?: string; | ||
@@ -19,5 +21,5 @@ } | ||
}; | ||
declare type ICDNIntlProviderProps = IBasicCDNIntlProviderProps & typeof defaultProps; | ||
export declare type ICDNIntlProviderProps = IBasicCDNIntlProviderProps & typeof defaultProps; | ||
interface IState { | ||
messages?: object; | ||
messages?: Messages; | ||
} | ||
@@ -24,0 +26,0 @@ export default class CDNIntlProvider extends Component<ICDNIntlProviderProps, IState> { |
@@ -5,3 +5,3 @@ import React, { Component } from 'react'; | ||
export const loadLanguage = async (resourcePath, project, variation, locale, stage) => { | ||
const countryCode = locale.split('_')[0]; | ||
const [countryCode] = locale.split('_'); | ||
const translations = await fetch(`${resourcePath}/${project}/${stage}/i18n/${countryCode}/${variation}.json`); | ||
@@ -8,0 +8,0 @@ return translations.json(); |
export { default } from './CDNIntlProvider'; | ||
export * from './CDNIntlProvider'; |
export { default } from './CDNIntlProvider'; | ||
export * from './CDNIntlProvider'; |
export { default } from './CDNIntlProvider'; | ||
export * from './CDNIntlProvider'; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var CDNIntlProvider_1 = require("./CDNIntlProvider"); | ||
exports.default = CDNIntlProvider_1.default; | ||
__export(require("./CDNIntlProvider")); |
{ | ||
"name": "@allthings/cdn-intl-provider", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"main": "dist/index.js", | ||
@@ -17,3 +17,4 @@ "module": "dist/es/index.js", | ||
"build": "yarn build:es && yarn build:cjs", | ||
"preversion": "yarn test", | ||
"preversion": "yarn test && yarn build", | ||
"postversion": "git push && git push --tags origin HEAD", | ||
"test": "jest" | ||
@@ -30,3 +31,2 @@ }, | ||
"@types/react-dom": "16.9.0", | ||
"@types/react-intl": "3.0.0", | ||
"jest": "24.9.0", | ||
@@ -33,0 +33,0 @@ "jest-fetch-mock": "2.1.2", |
@@ -12,3 +12,3 @@ # `CDNIntlProvider` | ||
- `react >= 16.3` | ||
- `react-intl >= 2.4` | ||
- `react-intl >= 3.0` | ||
@@ -15,0 +15,0 @@ ## Description |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
22615
14
493
0