<commit_before>package com.axelor.apps.prestashop.entities;

import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlValue;

public class PrestashopTranslatableString implements Cloneable {
	private List<PrestashopTranslationEntry> translations = new LinkedList<>();

	public PrestashopTranslatableString() {
	}

	private PrestashopTranslatableString(final PrestashopTranslatableString other) {
		for(PrestashopTranslationEntry entry : other.translations) {
			translations.add(new PrestashopTranslationEntry(entry));
		}
	}

	@XmlElement(name="language")
	public List<PrestashopTranslationEntry> getTranslations() {
		return translations;
	}

	@Override
	public PrestashopTranslatableString clone() {
		return new PrestashopTranslatableString(this);
	}

	public static class PrestashopTranslationEntry {
		private int languageId;
		private String translation;

		public PrestashopTranslationEntry() {
		}

		public PrestashopTranslationEntry(final PrestashopTranslationEntry other) {
			this.languageId = other.languageId;
			this.translation = other.translation;
		}

		@XmlAttribute(name="id")
		public int getLanguageId() {
			return languageId;
		}

		public void setLanguageId(int languageId) {
			this.languageId = languageId;
		}

		@XmlValue
		public String getTranslation() {
			return translation;
		}

		public void setTranslation(String translation) {<commit_msg>prestashop: helper function to get a translation in a given language<commit_after>package com.axelor.apps.prestashop.entities;

import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlValue;

public class PrestashopTranslatableString implements Cloneable {
	private List<PrestashopTranslationEntry> translations = new LinkedList<>();

	public PrestashopTranslatableString() {
	}

	private PrestashopTranslatableString(final PrestashopTranslatableString other) {
		for(PrestashopTranslationEntry entry : other.translations) {
			translations.add(new PrestashopTranslationEntry(entry));
		}
	}

	@XmlElement(name="language")
	public List<PrestashopTranslationEntry> getTranslations() {
		return translations;
	}

	@Override
	public PrestashopTranslatableString clone() {
		return new PrestashopTranslatableString(this);
	}

	public String getTranslation(final int language) {
		// If ever heavily used, consider using a Map
		for(PrestashopTranslationEntry e : translations) {
			if(e.getLanguageId() == language) return e.getTranslation();
		}
		return null;
	}

	public static class PrestashopTranslationEntry {
		private int languageId;
		private String translation;

		public PrestashopTranslationEntry() {
		}

		public PrestashopTranslationEntry(final PrestashopTranslationEntry other) {
			this.languageId = other.languageId;
			this.translation = other.translation;
		}

		@XmlAttribute(name="id")
		public int getLanguageId() {
			return languageId;
		}

		public void setLanguageId(int languageId) {
			this.languageId = languageId;
		}

		@XmlValue
		public String getTranslation() {
			return translation;
		}

		public void setTranslation(String translation) {
{'fraction_non_alphanumeric': 0.08340915984228087, 'fraction_numerical': 0.0, 'mean_word_length': 5.517786561264822, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1225282', 'n_tokens_mistral': 1038, 'n_tokens_neox': 941, 'n_words': 208}