# Name of language of translation

I am unhappy with my entity-relation-namings.

The underliyng tables are named TRANSLATION and LANGUAGE.

To contains translations like

German is German in English
Deutsch is German in German
English is English in English
Englisch is English in German


I have the table

LANGUAGE
ID (int pk)               <-- 1,2,3, ...
LANGTAG (varchar)         <-- en / de / fr / ...
TRANSLATION
LOCAL_NAME (varchar 64)   <-- German, Allemand, Deutsch, ...


Now I need relations between them. In the Entity i have both sides, the owning side and the non-owning-side.

I started using this relations:

You see two FKs:

1. Translates (getter in Translations) -> Translations (getter in Language)
2. Into language (getter in Translations) -> Language Translations (getter in Language)

But I inspect my Language-Entity now and see this:

private Set<Translation> translations = new LinkedHashSet<>();

@OneToMany(mappedBy = Translation.PROP_TRANSLATES)
public Set<Translation> getTranslations() {
return translations;
}

public Language setTranslations(final Set<Translation> translations) {
this.translations = translations;
return this;
}

private Set<Translation> languageTranslations = new LinkedHashSet<>();

@OneToMany(mappedBy = Translation.PROP_INTO_LANGUAGE)
public Set<Translation> getLanguageTranslations() {
return languageTranslations;
}

public Language setLanguageTranslations(final Set<Translation> languageTranslations) {
this.languageTranslations = languageTranslations;
return this;
}


I think the naming is problematic because I do not know what getter to use if I need the translations.

Intuitivly, to get the Languages that has been translated from German I use

Language german = entityManager.createCriteria("FROM Language WHERE langtag='de'");
Set<Translations> languagesInGerman = german.getLanguageTranslations();


The getter looks absolutly strange but I have no idea for a renaming!

• Maybe german.getNatives() but again I have no idea if i get a list of words translating German or a list of languages translated in german. – Grim Aug 30 '17 at 3:39
• Did you write this code or was it generated? – Phrancis Aug 30 '17 at 4:12
• I wrote it, why? – Grim Aug 30 '17 at 4:40
• Just the way it was worded made it sound like it may have been generated code. Thanks for clarifying. – Phrancis Aug 30 '17 at 4:42
• Well, maybegetLanguageNameInNativeLanguage? There's actually a term for that: endonym (and exonym, see wiki). So, getLanguageEndonym or something similar would look prettier, but a layman of the app doesn't understand it. If language is something important in the app, I would use the academic term. – slowy Aug 30 '17 at 9:52

(Proper answer from my comment in OP's question)

My proposal:

getLanguageNameInNativeLanguage

Other than that, there's a term for that: Endonym. See wiki: https://en.wikipedia.org/wiki/Exonym_and_endonym

Quote: An endonym or autonym is an internal name for a geographical place, or a group of people, or a language or dialect.

For instance, "Germany" is the English language exonym, "Allemagne" is the French language exonym, and "Deutschland" is the endonym for the same country in Europe.

getLanguageEndonym() or something similar would look prettier, but a layman of the app doesn't understand it. If language is something important in the app, I would use the "academic" term.