Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Translate SFTP/FTP
  • Loading branch information
iamgio committed Sep 7, 2018
1 parent f4878ea commit 7c14079
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 19 deletions.
11 changes: 10 additions & 1 deletion src/assets/lang/lang_en.properties
Expand Up @@ -113,4 +113,13 @@ replace.all=Replace all
replace.all.result=Replaced $1 results
replace.next.result=Replaced $1/$2
replace.no_matches=Nothing to replace
fetching=Fetching information...
fetching=Fetching information...
ftp.no_server=Add servers from Settings > FTP
sftp.no_server=Add servers from Settings > SFTP
remote.username=Username
remote.password=Password
remote.port=Port
remote.connect=Connect
remote.connecting=Connecting
remote.invalid=Invalid
remote.disconnecting=Disconnecting
15 changes: 12 additions & 3 deletions src/assets/lang/lang_it.properties
Expand Up @@ -8,12 +8,12 @@ bar.edit.search=Cerca
bar.edit.undo=Annulla
bar.edit.variables=Variabili
bar.file=File
bar.file.ftp=Apri da FTP
bar.file.ftp=Apri via FTP
bar.file.new=Crea file
bar.file.open=Apri
bar.file.refresh=Ricarica
bar.file.settings=Impostazioni
bar.file.sftp=Apri da SFTP
bar.file.sftp=Apri via SFTP
bar.file.test=Controlla file
bar.help=Aiuto
bar.help.check_for_updates=Cerca aggiornamenti
Expand Down Expand Up @@ -113,4 +113,13 @@ replace.all=Sostituisci tutto
replace.all.result=Sostituite $1 corrispondenze
replace.next.result=Sostituito $1/$2
replace.no_matches=Nessuna sostituzione disponibile
fetching=Raccogliendo le informazioni...
fetching=Raccogliendo le informazioni...
ftp.no_server=Aggiungi nuovi server da Impostazioni > FTP
sftp.no_server=Aggiungi nuovi server da Impostazioni > SFTP
remote.username=Nome
remote.password=Password
remote.port=Porta
remote.connect=Connetti
remote.connecting=Connessione
remote.invalid=Non valido
remote.disconnecting=Disconnessione
11 changes: 6 additions & 5 deletions src/org/chorusmc/chorus/menubar/file/OpenFromFTP.kt
Expand Up @@ -9,6 +9,7 @@ import org.chorusmc.chorus.connection.FTPRemoteConnection
import org.chorusmc.chorus.editor.EditorTab
import org.chorusmc.chorus.file.FTPFile
import org.chorusmc.chorus.menubar.MenuBarAction
import org.chorusmc.chorus.util.translate
import org.chorusmc.chorus.views.remoteconnection.ftp.FTPView

/**
Expand All @@ -25,27 +26,27 @@ class OpenFromFTP : MenuBarAction {
var connection: FTPRemoteConnection? = null
view.onConfirm { ip, username, port, password ->
if(connection != null && connection!!.isValid) {
view.title = "Disconnecting..."
view.title = "${translate("remote.disconnecting")}..."
connection!!.client!!.logout()
connection!!.client!!.disconnect()
}
view.title = "Connecting..."
view.title = "${translate("remote.connecting")}..."
connection = FTPRemoteConnection(ip, username, port, password)
val button = view.connectButton
if(connection!!.isValid) {
button.style = ""
button.text = "Connect"
button.text = translate("remote.connect")
val loc = lastLoc[ip]
if(loc != null) view.generateFiles(connection!!, loc) else view.generateFiles(connection!!)
} else {
view.clear()
view.title = "Chorus - FTP"
button.style = "-fx-border-width: 1; -fx-border-color: red"
button.text = " Invalid "
button.text = translate("remote.invalid")
WaitingTimer().start({
Platform.runLater {
button.style = ""
button.text = "Connect"
button.text = translate("remote.connect")
}}, Duration.seconds(1.5))
}
FTPRemoteConnection.psw = password
Expand Down
11 changes: 6 additions & 5 deletions src/org/chorusmc/chorus/menubar/file/OpenFromSFTP.kt
Expand Up @@ -9,6 +9,7 @@ import org.chorusmc.chorus.connection.SFTPRemoteConnection
import org.chorusmc.chorus.editor.EditorTab
import org.chorusmc.chorus.file.SFTPFile
import org.chorusmc.chorus.menubar.MenuBarAction
import org.chorusmc.chorus.util.translate
import org.chorusmc.chorus.views.remoteconnection.sftp.SFTPView

/**
Expand All @@ -25,26 +26,26 @@ class OpenFromSFTP : MenuBarAction {
var connection: SFTPRemoteConnection? = null
view.onConfirm { ip, username, port, password ->
if(connection != null && connection!!.isValid) {
view.title = "Disconnecting..."
view.title = "${translate("remote.disconnecting")}..."
connection!!.channel!!.disconnect()
connection!!.session.disconnect()
}
view.title = "Connecting..."
view.title = "${translate("remote.connecting")}..."
connection = SFTPRemoteConnection(ip, username, port, password)
val button = view.connectButton
if(connection!!.isValid) {
button.style = ""
button.text = "Connect"
button.text = translate("remote.connect")
val loc = lastLoc[ip]
if(loc != null) view.generateFiles(connection!!, loc) else view.generateFiles(connection!!)
} else {
view.clear()
view.title = "Chorus - SFTP"
button.style = "-fx-border-width: 1; -fx-border-color: red"
button.text = " Invalid "
button.text = translate("remote.invalid")
WaitingTimer().start({Platform.runLater {
button.style = ""
button.text = "Connect"
button.text = translate("remote.connect")
}}, Duration.seconds(1.5))
}
SFTPRemoteConnection.psw = password
Expand Down
Expand Up @@ -16,6 +16,7 @@ import org.chorusmc.chorus.nodes.control.NumericTextField
import org.chorusmc.chorus.theme.Themes
import org.chorusmc.chorus.util.config
import org.chorusmc.chorus.util.toObservableList
import org.chorusmc.chorus.util.translate

/**
* @author Gio
Expand All @@ -28,7 +29,7 @@ open class RemoteConnectionView(private val name: String, defaultPort: Int, sett
private val username = TextField()
private val password = PasswordField()
private val port = NumericTextField()
val connectButton = Button("Connect")
val connectButton = Button()
private val filesBox = VBox()

val stage = Stage()
Expand Down Expand Up @@ -70,16 +71,16 @@ open class RemoteConnectionView(private val name: String, defaultPort: Int, sett
port.text = pair.second
password.requestFocus()
}
ip.promptText = "Add servers from Settings > $name"
ip.promptText = translate("${name.toLowerCase()}.no_server")
ip.items = ips.keys.toList().toObservableList()
if(ip.items.size > 0) ip.selectionModel.selectFirst() else ip.isDisable = true
ip.styleClass += "ip-box"
username.promptText = "Username"
username.promptText = translate("remote.username")
username.styleClass += "username-field"
password.text = psw.psw
password.promptText = "Password"
password.promptText = translate("remote.password")
password.styleClass += "password-field"
port.promptText = "Port"
port.promptText = translate("remote.port")
port.styleClass += "username-field"
port.prefWidth = 40.0
port.alignment = Pos.CENTER
Expand All @@ -92,6 +93,7 @@ open class RemoteConnectionView(private val name: String, defaultPort: Int, sett
connectButton.fire()
}
password.disableProperty().bind(ip.selectionModel.selectedItemProperty().isNull)
connectButton.text = translate("remote.connect")
connectButton.styleClass += "connect-button"
connectButton.disableProperty().bind(
ip.selectionModel.selectedItemProperty().isNull
Expand Down

0 comments on commit 7c14079

Please sign in to comment.