-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add translate option for property setting dropdown list option …
…values - MEED-7999 - Meeds-io/MIPs#171 (#4325) Add translate option for profile property dropdown list option values
- Loading branch information
Showing
16 changed files
with
435 additions
and
127 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...main/java/org/exoplatform/social/core/plugin/ProfilePropertySettingOptionTranslation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../java/org/exoplatform/social/core/plugin/ProfilePropertySettingOptionTranslationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.