Background of the issue:
I need to add a script to my header that will change according to the language I am using. The script should change CodLang to 'HE' and Currency to 'ILS' for Hebrew, and to 'EN' and 'USD' for English. This is the code I have:
(function (i, s, o, g, r, a, m) {
i['SBSyncroBoxParam'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'hidden link','SBSyncroBox');
SBSyncroBox({
CodLang: 'HE',
Currency: 'ILS',
Styles: {Theme: "dark",
FontFamily: '"Rubik", Sans-serif',
CustomColor: "#3D3D3D", // Primary color
CustomColorHover: "#8CC741", // Primary hover color
CustomBGColor: "#3D3D3D", // Primary background color
CustomFieldBackgroundColor: "#F9F6EB", // Calendar fields background color
CustomLabelColor: "#F9F6EB", // Labels color
CustomLabelHoverColor: "#000000", // Lobels color on hover
CustomButtonColor:"#3D3D3D", // Buttons color
CustomButtonBGColor: "#43C8F5", // Buttons background color
CustomButtonHoverBGColor:"#8CC741", // Bottons background color on hover
CustomIconColor:"#43C8F5", // Icons color
CustomLinkColor: "#F9F6EB", // Links color
CustomWidgetColor: "#3D3D3D", // Widgets color
CustomWidgetBGColor: "#F9F6EB", // Widgets background color
CustomWidgetElementHoverColor: "#8CC741", // Widget elements color on hover
CustomWidgetElementHoverBGColor: "#fff", // Widget elements background color on hover
CustomBoxShadowColor:"#000000", // Box shadows color
CustomBoxShadowColorFocus:"#000000", // Box shadows color when have focus
CustomBoxShadowColorHover: "#000", // Box shadows color on hover
CustomAddRoomBoxShadowColor: "#000000", // Guests widget add room button border color
CustomIntentSelectionColor: "#000000", // Color of date range currently selected, when hovering on calendar
CustomIntentSelectionDaysBGColor: "#43C8F5", // Background color of intent selection cells
CustomSelectedDaysColor: "#fff", // Color of current selected range
CustomAccentColor: "#8CC741", // Calendar’s main color
CustomAccentColorHover: "#3D3D3D", // Calendar’s hover color
CustomCalendarBackgroundColor: "#F9F6EB", // Calendar’s background color
},
});
Symptoms:
None mentioned.
Questions:
How can I add a script to my header that changes according to the language I am using?
Welcome to the WPML support forum. Thanks for contacting us.
1. While waiting for one of my colleagues to help with this ticket, and based on what you've described, allow me to give you a quick example using our 'wpml_current_language' hook.
Ref: https://wpml.org/wpml-hook/wpml_current_language/
add_action( 'wp_head', function(){
$my_current_lang = apply_filters( 'wpml_current_language', NULL );
if ( $my_current_lang == 'fr' ){ ?>
<!-- Code for HE language here -->
<?php } elseif ( $my_current_lang == 'en' ){ ?>
<!-- Code for EN language here -->
<?php }
});
PS: This code should be added to your functions.php file.
In short:
- Go to "WPML > Support > Debug Information" (link)
- Copy the Debug Information from there.
- Find the private field I activated and paste that information.
Looking forward to hearing back from you.
Nico
The topic ‘[Closed] code issue’ is closed to new replies.