@kano/kbc-intl
Advanced tools
Comparing version 4.26.8-alpha.0 to 4.26.9-alpha.0
import { useIntl, defineMessages, injectIntl, IntlShape, FormattedMessage, WrappedComponentProps } from 'react-intl'; | ||
import { LanguageProvider } from './provider'; | ||
import * as kbcTranslations from './translations/i18n.js'; | ||
import { mergeTranslationMessages } from './utils'; | ||
import { mergeTranslationMessages, getLocale } from './utils'; | ||
interface IWithIntlProps extends WrappedComponentProps { | ||
@@ -14,3 +14,3 @@ } | ||
} | ||
export { defineMessages, kbcTranslations, useIntl, withIntl, IIntlShape, IWithIntlProps, FormattedMessage, LanguageProvider, mergeTranslationMessages }; | ||
export { defineMessages, kbcTranslations, useIntl, withIntl, IIntlShape, IWithIntlProps, FormattedMessage, LanguageProvider, mergeTranslationMessages, getLocale }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -20,2 +20,3 @@ "use strict"; | ||
exports.mergeTranslationMessages = utils_1.mergeTranslationMessages; | ||
exports.getLocale = utils_1.getLocale; | ||
; | ||
@@ -22,0 +23,0 @@ const withIntl = react_intl_1.injectIntl; |
import { ILocaleMessages } from './provider'; | ||
export declare const mergeTranslationMessages: (locales: any, translationMessages: any, kbcTranslationMessages: any) => ILocaleMessages; | ||
export declare function getLocale(available?: string[]): string; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -10,2 +10,25 @@ "use strict"; | ||
}; | ||
function getQueryVariable(variable) { | ||
const query = window.location.search.substring(1); | ||
const vars = query.split('&'); | ||
for (var i = 0; i < vars.length; i++) { | ||
const pair = vars[i].split('='); | ||
if (decodeURIComponent(pair[0]) == variable) { | ||
return decodeURIComponent(pair[1]); | ||
} | ||
} | ||
return null; | ||
} | ||
function getLocale(available = ['en-us']) { | ||
const browser = navigator.language.toLowerCase().slice(0, 2); | ||
const query = getQueryVariable('lang'); | ||
const lang = query || browser; | ||
for (const l of available) { | ||
if (lang === l.toLowerCase().slice(0, 2)) { | ||
return l; | ||
} | ||
} | ||
return available[0]; | ||
} | ||
exports.getLocale = getLocale; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@kano/kbc-intl", | ||
"version": "4.26.8-alpha.0", | ||
"version": "4.26.9-alpha.0", | ||
"description": "> TODO: description", | ||
@@ -38,3 +38,3 @@ "author": "Kano Computing", | ||
}, | ||
"gitHead": "7eaabcc72faed4841d436aa72bc4d28468af018d" | ||
"gitHead": "ec9b0a466f903d01431401306ec8545d5aa016db" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
18938
226