@@ -19,6 +19,7 @@ along with GanttProject. If not, see <http://www.gnu.org/licenses/>.
1919package net.sourceforge.ganttproject.gui.taskproperties
2020
2121import biz.ganttproject.app.LabelPosition
22+ import biz.ganttproject.app.MappingLocalizer
2223import biz.ganttproject.app.PropertySheetBuilder
2324import biz.ganttproject.app.RootLocalizer
2425import biz.ganttproject.colorFromUiManager
@@ -46,20 +47,21 @@ import javax.swing.SwingUtilities
4647
4748class MainPropertiesPanel (private val task : Task , private val taskView : TaskView ) {
4849 val title: String = RootLocalizer .formatText(" general" )
50+
4951 private val nameOption = ObservableString (" name" , task.name)
5052 private val milestoneOption = ObservableBoolean (" milestone" , task.isMilestone)
5153 private val taskDatesController = TaskDatesController (task, milestoneOption)
5254 private val projectTaskOption = ObservableBoolean (" projectTask" , task.isProjectTask)
5355 private val hasEarliestStart = ObservableBoolean (" hasEarliestStart" , task.thirdDateConstraint == 1 )
54- private val earliestStartOption = ObservableDate (" earliestStart " , if (task.thirdDateConstraint == 1 ) task.third.toLocalDate() else null )
56+ private val earliestStartOption = ObservableDate (" earliestBegin " , if (task.thirdDateConstraint == 1 ) task.third.toLocalDate() else null )
5557 private val priorityOption = ObservableEnum <Priority >(" priority" , task.priority, Priority .entries.toTypedArray())
5658 private val progressOption = ObservableInt (" progress" , task.completionPercentage)
5759 private val showInTimelineOption = ObservableBoolean (" showInTimeline" , taskView.timelineTasks.contains(task))
5860 private val colorOption = ObservableColor (" color" , Style .Color .parse(ColorOption .Util .getColor(task.color)))
5961 private val notesOption = ObservableString (" notes" , task.notes)
6062 private val webLinkOption = ObservableString (" webLink" , task.webLink)
6163 private val textureOption = ObservableEnum (" texture" , TaskTexture .find(task.shape) ? : TaskTexture .TRANSPARENT , TaskTexture .values())
62- private val copyStartDateAction = GPAction .create(" Copy Start Date " ) {
64+ private val copyStartDateAction = GPAction .create(" option.taskProperties.main.earliestBegin.copyBeginDate " ) {
6365 earliestStartOption.set(taskDatesController.startDateOption.value)
6466 }.also {
6567 it.putValue(GPAction .TEXT_DISPLAY , ContentDisplay .TEXT_ONLY )
@@ -77,10 +79,10 @@ class MainPropertiesPanel(private val task: Task, private val taskView: TaskView
7779 }
7880
7981 fun getFxNode () = StackPane ().apply {
80- background = Background (BackgroundFill (" Panel.background" .colorFromUiManager(), CornerRadii .EMPTY , Insets .EMPTY ))
81- val leftPane = PropertySheetBuilder (RootLocalizer ).pane {
82+ background = Background (BackgroundFill (" Panel.background" .colorFromUiManager(), CornerRadii .EMPTY , Insets .EMPTY ))
83+ val leftPane = PropertySheetBuilder (i18n ).pane {
8284 stylesheet(" /biz/ganttproject/task/TaskPropertiesDialog.css" )
83- title(RootLocalizer .create( " Main Properties " ) )
85+ title(" section.main " )
8486 text(nameOption)
8587 if (task.canBeProjectTask()) {
8688 checkbox(projectTaskOption)
@@ -121,7 +123,7 @@ class MainPropertiesPanel(private val task: Task, private val taskView: TaskView
121123 }
122124
123125 skip()
124- title(RootLocalizer .create( " View " ) )
126+ title(" section.view " )
125127 checkbox(showInTimelineOption)
126128 color(colorOption)
127129 dropdown(textureOption) {
@@ -134,16 +136,16 @@ class MainPropertiesPanel(private val task: Task, private val taskView: TaskView
134136 }
135137 val grid = GridPane ()
136138
137- val rightPane = PropertySheetBuilder (RootLocalizer ).pane {
139+ val rightPane = PropertySheetBuilder (i18n ).pane {
138140 stylesheet(" /biz/ganttproject/task/TaskPropertiesDialog.css" )
139- title(RootLocalizer .create( " Documents " ) )
141+ title(" section.documents " )
140142 text(notesOption) {
141143 isMultiline = true
142144 labelPosition = LabelPosition .ABOVE
143145 }
144146 text(webLinkOption) {
145147 editorStyles.add(" weblink" )
146- rightNode = Button (" Open " , FontAwesomeIconView (FontAwesomeIcon .EXTERNAL_LINK )).also {
148+ rightNode = Button (i18n.formatTextOrNull( " btn.open " ) , FontAwesomeIconView (FontAwesomeIcon .EXTERNAL_LINK )).also {
147149 it.contentDisplay = ContentDisplay .LEFT
148150 it.onAction = EventHandler { e ->
149151 webLinkOption.value?.let {
@@ -232,3 +234,26 @@ private fun Task.isProjectTaskOrContainsProjectTask(): Boolean {
232234 }
233235 return this .nestedTasks.any { it.isProjectTaskOrContainsProjectTask() }
234236}
237+
238+ private val labelLocalizer = MappingLocalizer (mapOf (
239+ " startDate" to { RootLocalizer .create(" dateOfBegining" ) },
240+ " endDate" to { RootLocalizer .create(" dateOfEnd" ) },
241+ " progress" to { RootLocalizer .create(" advancement" ) },
242+ " milestone" to { RootLocalizer .create(" meetingPoint" ) },
243+ " notes" to { RootLocalizer .create(" notesTask" ) },
244+ " color" to { RootLocalizer .create(" colors" ) },
245+ " texture" to { RootLocalizer .create(" shape" ) },
246+ ), unhandledKey = RootLocalizer ::create)
247+
248+ private val fallback = MappingLocalizer (mapOf (
249+ ), unhandledKey = {
250+ when {
251+ it.endsWith(" .label" ) -> labelLocalizer.create(it.removeSuffix(" .label" ))
252+ it.startsWith(" priority.value." ) -> RootLocalizer .create(" priority.${it.removePrefix(" priority.value." )} " )
253+ it == " btn.open" -> RootLocalizer .create(" storage.action.open" )
254+ else -> null
255+ }
256+ })
257+
258+ private val i18n = RootLocalizer .createWithRootKey(" option.taskProperties.main" , baseLocalizer = fallback)
259+
0 commit comments