Your variable named lang is a string because you're setting it to the value of the radio input, so lang.latitude, lang.longitude, lang.accuracy, lang.words, and lang.map are all undefined.
I'm assuming you have global variables such as de set since you said de.test works.
It would probably be easiest to put all of those languages into a single object that you can then reference by the key, or the value of the radio input. I've also added a variable that allows you to select the default language and the function that will be performing the actual html change.
var translate = {
default: 'en',
en: {
latitude: 'latitude',
longitude: 'longitude',
accuracy: 'accuracy',
words: 'words',
map: 'map',
},
de: {
latitude: '',
longitude: '',
accuracy: '',
words: '',
map: '',
},
fr: {
latitude: '',
longitude: '',
accuracy: '',
words: '',
map: '',
},
changeText: function(lang) {
$('#latitude-n').html(translate[lang].latitude);
$('#longitude-n').html(translate[lang].longitude);
$('#accuracy-n').html(translate[lang].accuracy);
$('#words-n').html(translate[lang].words);
$('#map-n').html(translate[lang].map);
}
}
Since you didn't post the HTML of your three radio buttons, I'm going to instead give them name attributes instead of id's of with the value "lang-settings" because having duplicate id's is invalid HTML. Below is the minimal HTML for these radio buttons.
<input name="lang-setting" value="en" type="radio" />
<input name="lang-setting" value="de" type="radio" />
<input name="lang-setting" value="fr" type="radio" />
Then for your listener, I've switched it to listen for "clicks" instead of changing, because the values of the radio button isn't actually changing, they're staying as "en", "de", and "fr". I've also added the function call in document ready to run your default language selection on page load.
$('input[name="lang-setting"]').on('click', function(e){
var lang = $(this).val();
translate.changeText(lang);
});
$(document).ready(function(){
translate.changeText(translate.default);
});
Here's a working demo of it on JSFiddle