/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.api;

import java.util.Map;
import java.util.TreeMap;

public interface Translator {
	public default String translate(String language, String text){
		var parts = text.split("\\|");
		var fills = new TreeMap<String,String>();
		if (parts.length>1) for (var idx=1;idx<parts.length;idx++){
			var nested = parts[idx].split("=",2);
			if (nested.length<2){
				fills.put("{"+idx+"}",nested[0]);
			} else fills.put(nested[0],nested[1]);
		}
		return translate(language, parts[0], fills);
	}

	public String translate(String language, String text, Map<String,String> fills);
}
