recruitmentBanner helper using englishInAcceptLanguages

This commit is contained in:
Luke Crouch 2020-10-08 11:31:57 -05:00
Родитель c996d7925b
Коммит 45cb1e49a4
2 изменённых файлов: 22 добавлений и 3 удалений

Просмотреть файл

@ -21,6 +21,25 @@ function getSupportedLocales(args) {
}
function englishInAcceptLanguages(args) {
const acceptedLanguages = args.data.root.req.acceptsLanguages();
return acceptedLanguages.some(locale => locale.startsWith("en"));
}
function recruitmentBanner(args) {
if (!AppConstants.RECRUITMENT_BANNER_LINK || !AppConstants.RECRUITMENT_BANNER_TEXT) {
return;
}
if (!englishInAcceptLanguages(args)) {
return;
}
return `<div class="recruitment-banner"><a id="recruitment-banner" href="${AppConstants.RECRUITMENT_BANNER_LINK}" target="_blank" rel="noopener noreferrer" data-ga-link="" data-event-category="Recruitment" data-event-label="${AppConstants.RECRUITMENT_BANNER_TEXT}">${AppConstants.RECRUITMENT_BANNER_TEXT}</a></div>`;
}
function getString (id, args) {
const supportedLocales = getSupportedLocales(args);
return LocaleUtils.fluentFormat(supportedLocales, id, args.hash);
@ -169,6 +188,8 @@ function breachMath(lValue, operator = null, rValue = null) {
module.exports = {
recruitmentBanner,
englishInAcceptLanguages,
getString,
getStrings,
fluentFxa,

Просмотреть файл

@ -1,7 +1,5 @@
<header id="header" class="{{ addUpgradeClasses }}">
{{#if RECRUITMENT_BANNER_LINK }}
<div class="recruitment-banner"><a id="recruitment-banner" href="{{ RECRUITMENT_BANNER_LINK }}" target="_blank" rel="noopener noreferrer" data-ga-link="" data-event-category="Recruitment" data-event-label="{{ RECRUITMENT_BANNER_TEXT }}">{{ RECRUITMENT_BANNER_TEXT }}</a></div>
{{/if}}
{{{ recruitmentBanner }}}
<div id="navigation-wrapper" class="{{ addUpgradeClasses }}">
<section class="row-full-width fxm-branding">
<a class="flx-cntr fx-monitor-logo-wrapper" href="/" aria-label="{{ getString 'home' }}" {{> analytics/internal-link eventLabel="Fx-Monitor-Logo" }}>