forked from eclipse-sirius/sirius-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3464] Improve i18n support for domain and view forms
Bug: eclipse-sirius#3464 Signed-off-by: Denis Nikiforov <[email protected]>
- Loading branch information
Showing
32 changed files
with
1,143 additions
and
88 deletions.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
...orms/src/main/java/org/eclipse/sirius/components/emf/forms/EEnumLiteralLabelProvider.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,66 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.emf.forms; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.emf.common.notify.Adapter; | ||
import org.eclipse.emf.common.notify.AdapterFactory; | ||
import org.eclipse.emf.common.util.Enumerator; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.ecore.EStructuralFeature; | ||
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; | ||
import org.eclipse.emf.edit.provider.IItemPropertySource; | ||
import org.eclipse.sirius.components.forms.components.SelectComponent; | ||
import org.eclipse.sirius.components.representations.VariableManager; | ||
|
||
/** | ||
* Utility class used to provide a label for an enumeration literal in the variable manager. | ||
* | ||
* @author aresekb | ||
*/ | ||
public class EEnumLiteralLabelProvider implements Function<VariableManager, String> { | ||
|
||
private final String featureVariableName; | ||
|
||
private final AdapterFactory adapterFactory; | ||
|
||
public EEnumLiteralLabelProvider(String featureVariableName, AdapterFactory adapterFactory) { | ||
this.featureVariableName = Objects.requireNonNull(featureVariableName); | ||
this.adapterFactory = Objects.requireNonNull(adapterFactory); | ||
} | ||
|
||
@Override | ||
public String apply(VariableManager variableManager) { | ||
Object object = variableManager.getVariables().get(VariableManager.SELF); | ||
Object feature = variableManager.getVariables().get(this.featureVariableName); | ||
Object literal = variableManager.getVariables().get(SelectComponent.CANDIDATE_VARIABLE); | ||
|
||
String result = ""; | ||
if (object instanceof EObject eObject && feature instanceof EStructuralFeature eStructuralFeature) { | ||
Adapter adapter = this.adapterFactory.adapt(eObject, IItemPropertySource.class); | ||
if (adapter instanceof IItemPropertySource itemPropertySource) { | ||
IItemPropertyDescriptor descriptor = itemPropertySource.getPropertyDescriptor(eObject, eStructuralFeature); | ||
if (descriptor != null) { | ||
result = descriptor.getLabelProvider(eObject).getText(literal); | ||
} | ||
} | ||
} | ||
if (result.isEmpty() && literal instanceof Enumerator enumerator) { | ||
result = enumerator.getLiteral(); | ||
} | ||
return result; | ||
} | ||
|
||
} |
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
20 changes: 20 additions & 0 deletions
20
...mf/backend/sirius-components-emf/src/main/resources/messages/sirius-web-emf_ru.properties
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,20 @@ | ||
################################################################################ | ||
# Copyright (c) 2024 Obeo. | ||
# This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v2.0 | ||
# which accompanies this distribution, and is available at | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Obeo - initial API and implementation | ||
################################################################################# | ||
INVALID_INPUT = \u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0442\u0438\u043F, \u0431\u044B\u043B\u043E \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E "{0}", \u0430 \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C "{1}" | ||
UNEXPECTED_ERROR = \u041F\u0440\u043E\u0438\u0437\u043E\u0448\u043B\u0430 \u043D\u0435\u043E\u0436\u0438\u0434\u0430\u043D\u043D\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430, \u0441\u0432\u044F\u0436\u0438\u0442\u0435\u0441\u044C, \u043F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0441 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u043E\u043C | ||
INVALID_NUMBER = \u041D\u043E\u0432\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 "{0}" \u043D\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0447\u0438\u0441\u043B\u043E\u043C | ||
UPPER_BOUNDARY_REACHED = \u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043E\u0431\u044A\u0435\u043A\u0442 "{0}" \u0432 \u043A\u043E\u043B\u043B\u0435\u043A\u0446\u0438\u0438 "{1}", \u043F\u043E\u0442\u043E\u043C\u0443 \u0447\u0442\u043E \u0434\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442 \u043F\u0440\u0435\u0434\u0435\u043B \u043D\u0430 \u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432. | ||
PROPERTIES = \u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 | ||
CORE_PROPERTIES = \u041E\u0441\u043D\u043E\u0432\u043D\u044B\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430 | ||
GENERAL = \u041E\u0431\u0449\u0438\u0435 | ||
SHAPE_PREVIEW = \u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u0444\u0438\u0433\u0443\u0440\u044B |
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.