How to use the @paypal/sdk-constants/src.COUNTRY_LANGS.hasOwnProperty function in @paypal/sdk-constants

To help you get started, we’ve selected a few @paypal/sdk-constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / paypal-sdk-client / src / script.js View on Github external
if (locale) {
        const [ lang, country ] = locale.split('_');
        return { lang, country };
    }
    
    for (const { country, lang } of getBrowserLocales()) {
        // $FlowFixMe
        if (COUNTRY_LANGS.hasOwnProperty(country) && COUNTRY_LANGS[country].indexOf(lang) !== -1) {
            // $FlowFixMe
            return { country, lang };
        }
    }

    for (const { country } of getBrowserLocales()) {
        // $FlowFixMe
        if (COUNTRY_LANGS.hasOwnProperty(country)) {
            // $FlowFixMe
            return { country, lang: COUNTRY_LANGS[country][0] };
        }
    }

    return {
        lang:    LANG.EN,
        country: COUNTRY.US
    };
}
github paypal / paypal-sdk-client / src / script.js View on Github external
export function getLocale() : LocaleType {
    const locale = getSDKQueryParam(SDK_QUERY_KEYS.LOCALE);

    if (locale) {
        const [ lang, country ] = locale.split('_');
        return { lang, country };
    }
    
    for (const { country, lang } of getBrowserLocales()) {
        // $FlowFixMe
        if (COUNTRY_LANGS.hasOwnProperty(country) && COUNTRY_LANGS[country].indexOf(lang) !== -1) {
            // $FlowFixMe
            return { country, lang };
        }
    }

    for (const { country } of getBrowserLocales()) {
        // $FlowFixMe
        if (COUNTRY_LANGS.hasOwnProperty(country)) {
            // $FlowFixMe
            return { country, lang: COUNTRY_LANGS[country][0] };
        }
    }

    return {
        lang:    LANG.EN,
        country: COUNTRY.US