DefaultEntityLocalizationService implements EntityLocalizationService { @Override public <T extends Localized> T localize(T entity) { if (this.context == null || !this.context.isAlternativeLocale()) { return entity; } else { return localize(entity, this.context.getLocale()); } }  @Override T localize(T entity); @Override T localize(T entity, Locale locale);  }
@Test public void testEntityLocalization() throws ComponentLookupException { Map<Locale, Map<String, Object>> versions = Maps.newHashMap(); Map<String, Object> englishLocale = Maps.newHashMap(); englishLocale.put("localizedString", "I am a Berliner"); versions.put(new Locale("en"), englishLocale); Map<String, Object> germanLocale = Maps.newHashMap(); germanLocale.put("localizedString", "Ich bin ein Berliner"); versions.put(new Locale("de"), germanLocale); TestEntity entity = new TestEntity(UUID.randomUUID(), "test", versions); entity.setLocalizedString("Je suis un Berlinois"); TestEntity inEnglish = this.componentManager.getComponentUnderTest().localize(entity, Locale.ENGLISH); Assert.assertNotSame(entity, inEnglish); TestEntity inGerman = this.componentManager.getComponentUnderTest().localize(entity, Locale.GERMAN); Assert.assertEquals("Je suis un Berlinois", entity.getLocalizedString()); Assert.assertEquals("I am a Berliner", inEnglish.getLocalizedString()); Assert.assertEquals("Ich bin ein Berliner", inGerman.getLocalizedString()); }