<commit_before>package org.orienteer.core.util;

import java.io.Serializable;
import java.util.Locale;
import java.util.Map;

import org.orienteer.core.OrienteerWebSession;

import com.google.common.base.Function;

/**
 * {@link Function} to localize input value
 *
 * @param <F> type of source object
 */
public class LocalizeFunction<F> implements Function<F, String>, Serializable{

	private static final LocalizeFunction<?> INSTANCE = new LocalizeFunction<Object>();
	
	public static <M> LocalizeFunction<M> getInstance() {
		return (LocalizeFunction<M>) INSTANCE;
	}
	
	@Override
	public String apply(F input) {
		Object value = input;
		if(value instanceof Map) {
			Map<?,?> map = (Map<?, ?>) value;
	        if (value != null) {
	            String currentLanguage = OrienteerWebSession.get().getLocale().getLanguage();
	            value = map.get(currentLanguage);
	            if (value == null) {
	                value = map.get(Locale.getDefault().getLanguage());
	            }
	        }
		}
		return CommonUtils.objectToString(value, null);
	}

}
<commit_msg>Localized map should show at least first value<commit_after>package org.orienteer.core.util;

import java.io.Serializable;
import java.util.Locale;
import java.util.Map;

import org.orienteer.core.OrienteerWebSession;

import com.google.common.base.Function;

/**
 * {@link Function} to localize input value
 *
 * @param <F> type of source object
 */
public class LocalizeFunction<F> implements Function<F, String>, Serializable{

	private static final LocalizeFunction<?> INSTANCE = new LocalizeFunction<Object>();
	
	public static <M> LocalizeFunction<M> getInstance() {
		return (LocalizeFunction<M>) INSTANCE;
	}
	
	@Override
	public String apply(F input) {
		Object value = input;
		if(value instanceof Map) {
            value = CommonUtils.localizeByMap((Map<String, ?>) value, true, 
            			OrienteerWebSession.get().getLocale().getLanguage(), 
            			Locale.getDefault().getLanguage());
		} 
		return CommonUtils.objectToString(value, null);
	}

}

{'fraction_non_alphanumeric': 0.12298682284040996, 'fraction_numerical': 0.0, 'mean_word_length': 3.680365296803653, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563620', 'n_tokens_mistral': 644, 'n_tokens_neox': 604, 'n_words': 150}