externalize strings in chat server tab

pull/53/head
Zlatin Balevsky 2020-09-29 14:34:15 +01:00
parent 6e98d96bc1
commit 7f9ebe0850
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 16 additions and 9 deletions

View File

@ -16,14 +16,14 @@ class ChatServerController {
@ControllerAction @ControllerAction
void disconnect() { void disconnect() {
switch(model.buttonText) { switch(model.buttonText) {
case "Disconnect" : case "DISCONNECT" :
model.buttonText = "Connect" model.buttonText = "CONNECT"
mvcGroup.getChildrenGroups().each { k,v -> mvcGroup.getChildrenGroups().each { k,v ->
v.controller.serverDisconnected() v.controller.serverDisconnected()
} }
model.core.eventBus.publish(new UIDisconnectChatEvent(host : model.host)) model.core.eventBus.publish(new UIDisconnectChatEvent(host : model.host))
break break
case "Connect" : case "CONNECT" :
model.connect() model.connect()
break break
} }

View File

@ -443,3 +443,9 @@ QUERY=Query
GENERATING_PREVIEW=Generating Preview GENERATING_PREVIEW=Generating Preview
GENERATING_PREVIEW_FOR=Generating preview for {0} GENERATING_PREVIEW_FOR=Generating preview for {0}
PREVIEW_SEQUENTIAL_NOTICE=This download is not sequential, there may not be much to preview PREVIEW_SEQUENTIAL_NOTICE=This download is not sequential, there may not be much to preview
## Chat server tab
CONNECT=Connect
DISCONNECT=Disconnect
LOCAL_SERVER=Local Server
CONNECTION_STATUS=Connection Status

View File

@ -30,7 +30,7 @@ class ChatServerModel {
Core core Core core
@Observable boolean disconnectActionEnabled @Observable boolean disconnectActionEnabled
@Observable String buttonText = "Disconnect" @Observable String buttonText = "DISCONNECT"
@Observable ChatConnectionAttemptStatus status @Observable ChatConnectionAttemptStatus status
@Observable boolean sayActionEnabled @Observable boolean sayActionEnabled
@ -47,7 +47,7 @@ class ChatServerModel {
void connect() { void connect() {
runInsideUIAsync { runInsideUIAsync {
buttonText = "Disconnect" buttonText = "DISCONNECT"
} }
core.eventBus.publish(new UIConnectChatEvent(host : host)) core.eventBus.publish(new UIConnectChatEvent(host : host))
} }

View File

@ -1,6 +1,7 @@
package com.muwire.gui package com.muwire.gui
import griffon.core.artifact.GriffonView import griffon.core.artifact.GriffonView
import static com.muwire.gui.Translator.trans
import griffon.inject.MVCMember import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor import griffon.metadata.ArtifactProviderFor
import javax.swing.SwingConstants import javax.swing.SwingConstants
@ -34,10 +35,10 @@ class ChatServerView {
gridLayout(rows : 1, cols : 3) gridLayout(rows : 1, cols : 3)
panel {} panel {}
panel { panel {
button(text : bind {model.buttonText}, enabled : bind {model.disconnectActionEnabled}, disconnectAction) button(text : bind {trans(model.buttonText)}, enabled : bind {model.disconnectActionEnabled}, disconnectAction)
} }
panel { panel {
label(text : "Connection Status ") label(text : trans("CONNECTION_STATUS") + " ")
label(text : bind {model.status.toString()}) label(text : bind {model.status.toString()})
} }
} }
@ -59,7 +60,7 @@ class ChatServerView {
tabPanel = panel { tabPanel = panel {
borderLayout() borderLayout()
panel (constraints : BorderLayout.CENTER) { panel (constraints : BorderLayout.CENTER) {
String text = model.host == model.core.me ? "Local Server" : model.host.getHumanReadableName() String text = model.host == model.core.me ? trans("LOCAL_SERVER") : model.host.getHumanReadableName()
label(text : text) label(text : text)
} }
button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST, button(icon : imageIcon("/close_tab.png"), preferredSize: [20, 20], constraints : BorderLayout.EAST,
@ -83,7 +84,7 @@ class ChatServerView {
if (model.host == model.core.me) { if (model.host == model.core.me) {
mvcGroup.parentGroup.controller.stopChatServer() mvcGroup.parentGroup.controller.stopChatServer()
} }
else if (model.buttonText == "Disconnect") else if (model.buttonText == "DISCONNECT")
controller.disconnect() controller.disconnect()
int index = parent.indexOfComponent(pane) int index = parent.indexOfComponent(pane)
parent.removeTabAt(index) parent.removeTabAt(index)