Skip to content

Commit

Permalink
feat: Add translate option for property setting dropdown list option …
Browse files Browse the repository at this point in the history
…values - MEED-7999 - Meeds-io/MIPs#171 (#4325)

Add translate option for profile property dropdown list option values
  • Loading branch information
hakermi committed Jan 10, 2025
1 parent 7e81b3a commit 8268f3b
Show file tree
Hide file tree
Showing 16 changed files with 435 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2025 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package org.exoplatform.social.core.plugin;

import io.meeds.social.translation.plugin.TranslationPlugin;
import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.portal.config.UserACL;

public class ProfilePropertySettingOptionTranslation extends TranslationPlugin {

private final UserACL userACL;

public static final String PROFILE_PROPERTY_SETTING_OPTION_OBJECT_TYPE = "propertySettingOption";

public ProfilePropertySettingOptionTranslation(UserACL userACL) {
this.userACL = userACL;
}

@Override
public String getObjectType() {
return PROFILE_PROPERTY_SETTING_OPTION_OBJECT_TYPE;
}

@Override
public boolean hasAccessPermission(long objectId, String username) throws ObjectNotFoundException {
return userACL.isAdministrator(userACL.getUserIdentity(username));
}

@Override
public boolean hasEditPermission(long objectId, String username) throws ObjectNotFoundException {
return userACL.isAdministrator(userACL.getUserIdentity(username));
}

@Override
public long getAudienceId(long objectId) throws ObjectNotFoundException {
return 0;
}

@Override
public long getSpaceId(long objectId) throws ObjectNotFoundException {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.exoplatform.social.core.jpa.test;

import org.exoplatform.social.core.plugin.ProfilePropertySettingOptionTranslationTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runners.Suite.SuiteClasses;
Expand Down Expand Up @@ -128,7 +129,8 @@
ComplementaryFilterSearchConnectorTest.class,
ProfileIndexingServiceConnectorTest.class,
OrganizationalChartHeaderTranslationTest.class,
ManagerPropertySettingUpdatedListenerTest.class
ManagerPropertySettingUpdatedListenerTest.class,
ProfilePropertySettingOptionTranslationTest.class,
})
@ConfigTestCase(AbstractCoreTest.class)
public class InitContainerTestSuite extends BaseExoContainerTestSuite {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2025 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package org.exoplatform.social.core.plugin;

import io.meeds.social.translation.model.TranslationField;
import io.meeds.social.translation.service.TranslationService;
import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.component.test.AbstractKernelTest;
import org.exoplatform.component.test.ConfigurationUnit;
import org.exoplatform.component.test.ConfiguredBy;
import org.exoplatform.component.test.ContainerScope;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

@ConfiguredBy({
@ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/exo.social.component.core-local-configuration.xml") })
public class ProfilePropertySettingOptionTranslationTest extends AbstractKernelTest {

private TranslationService translationService;

@Override
public void setUp() throws Exception {
super.setUp();
translationService = getContainer().getComponentInstanceOfType(TranslationService.class);
begin();
}

public void testTranslatePropertyOption() throws ObjectNotFoundException {

Map<Locale, String> labels = new HashMap<>();
labels.put(Locale.US, "option en");
labels.put(Locale.FRANCE, "option fr");
translationService.saveTranslationLabels("propertySettingOption", 1L, "optionValue", labels);

TranslationField translationField = translationService.getTranslationField("propertySettingOption", 1L, "optionValue");
assertNotNull(translationField);
assertNotNull(translationField.getLabels());
assertEquals(2, translationField.getLabels().size());
end();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.OrganizationalChartHeaderTranslation</type>
</component-plugin>
<component-plugin>
<name>profilePropertySettingOption</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.ProfilePropertySettingOptionTranslation</type>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
<type>org.exoplatform.social.webNotification.service.test.MockWebNotificationStorage</type>
</component>

<external-component-plugins>
<target-component>io.meeds.social.translation.service.TranslationService</target-component>
<component-plugin>
<name>organizationalChart</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.OrganizationalChartHeaderTranslation</type>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
<target-component>io.meeds.social.translation.service.TranslationService</target-component>
<component-plugin>
Expand All @@ -63,6 +54,16 @@
<set-method>addPlugin</set-method>
<type>io.meeds.social.link.plugin.LinkTranslationPlugin</type>
</component-plugin>
<component-plugin>
<name>organizationalChart</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.OrganizationalChartHeaderTranslation</type>
</component-plugin>
<component-plugin>
<name>profilePropertySettingOption</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.ProfilePropertySettingOptionTranslation</type>
</component-plugin>
</external-component-plugins>

<!-- Notifications plugins required for IntranetNotificationsRestServiceTest -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ profileSettings.dropdownList.value.validate.label=Validate
profileSettings.dropdownList.value.cancel.label=Cancel
profileSettings.dropdownList.no.values.label=No values
profileSettings.dropdownList.actions.ariaLabel=Property option actions
profileSettings.dropdownList.translation.title=Value name
#####################################################################################
# Translation Drawer #
#####################################################################################
Expand All @@ -927,6 +928,7 @@ translationDrawer.apply=Apply
translationDrawer.existingTranslationsTooltip={0} translations added
translationDrawer.noTranslationsTooltip=Click to add translations

translationButton.ariaLabel=Add translation
#####################################################################################
# Image Crop Drawer #
#####################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ profileSettings.dropdownList.value.validate.label=Valider
profileSettings.dropdownList.value.cancel.label=Annuler
profileSettings.dropdownList.no.values.label=Aucune valeur
profileSettings.dropdownList.actions.ariaLabel=Actions sur les options de propri\u00E9t\u00E9
profileSettings.dropdownList.translation.title=Nom de la valeur
#####################################################################################
# Translation Drawer #
#####################################################################################
Expand All @@ -927,6 +928,7 @@ translationDrawer.apply=Appliquer
translationDrawer.existingTranslationsTooltip={0} traductions ajoutées
translationDrawer.noTranslationsTooltip=Cliquer pour ajouter des traductions

translationButton.ariaLabel=Ajouter une traduction
#####################################################################################
# Image Crop Drawer #
#####################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,11 @@
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.OrganizationalChartHeaderTranslation</type>
</component-plugin>
<component-plugin>
<name>profilePropertySettingOption</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.social.core.plugin.ProfilePropertySettingOptionTranslation</type>
</component-plugin>
</external-component-plugins>
<external-component-plugins>
<target-component>io.meeds.social.translation.service.TranslationService</target-component>
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,9 @@
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>translationField</module>
</depends>
<depends>
<module>jquery</module>
<as>$</as>
Expand Down
Loading

0 comments on commit 8268f3b

Please sign in to comment.