As a beginner in programming, I successfully added the linkedin share button to my test webpage. Now, I am hoping to make the button change language based on the user's language selection on the webpage.
Linkedin uses a five character language code (ru_RU, en_US, ko_KR, etc), while my test webpage utilizes a two character language code (ru, en, ko). Therefore, I need to create a javascript function that will convert the two character code to the five character code.
Currently, I am using django 1.4 and accessing the language preference with "{{ user.get_profile.language_preference }}" which returns the two character language code.
Below is the script I tried to create for converting the language code:
<script type="text/javascript">
function language_code_extended(){
var language_code_value = "{{ user.get_profile.language_preference }}";
if ( language_code_value == ru ) {
return "ru_RU"
}
else if ( language_code_value == "fr" ) {
return "fr_FR"
}
else if ( language_code_value == "ko" ) {
return "ko_KR"
}
else {
return "en_US"
}
}
</script>
And here is the code for my linkedin share button:
<!-- LinkedIn Like Button code -->
<script src="//platform.linkedin.com/in.js" type="text/javascript">
//lang: ru_RU
lang: language_code_extended()
</script>
Unfortunately, this setup is not functioning as intended. Can anyone identify where I may be going wrong?
Thank you.