mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
type the translations
This commit is contained in:
parent
5d40c084a5
commit
129c9bbe9e
17 changed files with 123 additions and 132 deletions
2
main.go
2
main.go
|
|
@ -54,6 +54,6 @@ func main() {
|
|||
stackTrace := newErr.ErrorStack()
|
||||
app.Log.Error(stackTrace)
|
||||
|
||||
log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.SLocalize("ErrorOccurred"), stackTrace))
|
||||
log.Fatal(fmt.Sprintf("%s\n\n%s", app.Tr.ErrorOccurred, stackTrace))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ type App struct {
|
|||
OSCommand *commands.OSCommand
|
||||
DockerCommand *commands.DockerCommand
|
||||
Gui *gui.Gui
|
||||
Tr *i18n.Localizer
|
||||
Tr i18n.TranslationSet
|
||||
ErrorChan chan error
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ func NewApp(config *config.AppConfig) (*App, error) {
|
|||
}
|
||||
var err error
|
||||
app.Log = log.NewLogger(config, "23432119147a4367abf7c0de2aa99a2d")
|
||||
app.Tr := i18n.NewTranslationSet(logger)
|
||||
app.Tr = i18n.NewTranslationSet(app.Log)
|
||||
app.OSCommand = commands.NewOSCommand(app.Log, config)
|
||||
|
||||
// here is the place to make use of the docker-compose.yml file in the current directory
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
type DockerCommand struct {
|
||||
Log *logrus.Entry
|
||||
OSCommand *OSCommand
|
||||
Tr *i18n.Localizer
|
||||
Tr i18n.TranslationSet
|
||||
Config *config.AppConfig
|
||||
Client *client.Client
|
||||
InDockerComposeProject bool
|
||||
|
|
@ -37,7 +37,7 @@ type DockerCommand struct {
|
|||
}
|
||||
|
||||
// NewDockerCommand it runs git commands
|
||||
func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.Localizer, config *config.AppConfig, errorChan chan error) (*DockerCommand, error) {
|
||||
func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*DockerCommand, error) {
|
||||
cli, err := client.NewEnvClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func NewDummyDockerCommandWithOSCommand(osCommand *OSCommand) *DockerCommand {
|
|||
return &DockerCommand{
|
||||
Log: NewDummyLog(),
|
||||
OSCommand: osCommand,
|
||||
Tr: i18n.NewLocalizer(NewDummyLog()),
|
||||
Tr: i18n.NewTranslationSet(NewDummyLog()),
|
||||
Config: NewDummyAppConfig(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,16 +130,6 @@ func (gui *Gui) createPopupPanel(g *gocui.Gui, currentView *gocui.View, title, p
|
|||
}
|
||||
|
||||
func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {
|
||||
actions := gui.Tr.TemplateLocalize(
|
||||
"CloseConfirm",
|
||||
Teml{
|
||||
"keyBindClose": "esc",
|
||||
"keyBindConfirm": "enter",
|
||||
},
|
||||
)
|
||||
if err := gui.renderString(g, "options", actions); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone, gui.wrappedConfirmationFunction(handleConfirm)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -168,7 +158,7 @@ func (gui *Gui) createSpecificErrorPanel(message string, nextView *gocui.View, w
|
|||
|
||||
colorFunction := color.New(color.FgRed).SprintFunc()
|
||||
coloredMessage := colorFunction(strings.TrimSpace(message))
|
||||
return gui.createConfirmationPanel(gui.g, nextView, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil)
|
||||
return gui.createConfirmationPanel(gui.g, nextView, gui.Tr.ErrorTitle, coloredMessage, nil, nil)
|
||||
}
|
||||
|
||||
func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error {
|
||||
|
|
|
|||
|
|
@ -350,17 +350,17 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
options := []*removeContainerOption{
|
||||
{
|
||||
description: gui.Tr.SLocalize("remove"),
|
||||
description: gui.Tr.Remove,
|
||||
command: "docker rm " + container.ID[1:10],
|
||||
configOptions: types.ContainerRemoveOptions{},
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("removeWithVolumes"),
|
||||
description: gui.Tr.RemoveWithVolumes,
|
||||
command: "docker rm --volumes " + container.ID[1:10],
|
||||
configOptions: types.ContainerRemoveOptions{RemoveVolumes: true},
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("cancel"),
|
||||
description: gui.Tr.Cancel,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -370,13 +370,13 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
configOptions := options[index].configOptions
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.RemovingStatus, func() error {
|
||||
if cerr := container.Remove(configOptions); cerr != nil {
|
||||
var originalErr commands.ComplexError
|
||||
if xerrors.As(cerr, &originalErr) {
|
||||
if originalErr.Code == commands.MustStopContainer {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("mustForceToRemoveContainer"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.Confirm, gui.Tr.MustForceToRemoveContainer, func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.RemovingStatus, func() error {
|
||||
configOptions.Force = true
|
||||
if err := container.Remove(configOptions); err != nil {
|
||||
return err
|
||||
|
|
@ -404,8 +404,8 @@ func (gui *Gui) handleContainerStop(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("StopContainer"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("StoppingStatus"), func() error {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.Confirm, gui.Tr.StopContainer, func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error {
|
||||
if err := container.Stop(); err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
|
@ -422,7 +422,7 @@ func (gui *Gui) handleContainerRestart(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RestartingStatus"), func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.RestartingStatus, func() error {
|
||||
if err := container.Restart(); err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,15 +44,12 @@ type SentinelErrors struct {
|
|||
// localising things in the code.
|
||||
func (gui *Gui) GenerateSentinelErrors() {
|
||||
gui.Errors = SentinelErrors{
|
||||
ErrSubProcess: errors.New(gui.Tr.SLocalize("RunningSubprocess")),
|
||||
ErrNoContainers: errors.New(gui.Tr.SLocalize("NoContainers")),
|
||||
ErrNoImages: errors.New(gui.Tr.SLocalize("NoImages")),
|
||||
ErrSubProcess: errors.New(gui.Tr.RunningSubprocess),
|
||||
ErrNoContainers: errors.New(gui.Tr.NoContainers),
|
||||
ErrNoImages: errors.New(gui.Tr.NoImages),
|
||||
}
|
||||
}
|
||||
|
||||
// Teml is short for template used to make the required map[string]interface{} shorter when using gui.Tr.SLocalize and gui.Tr.TemplateLocalize
|
||||
type Teml i18n.Teml
|
||||
|
||||
// Gui wraps the gocui Gui object which handles rendering and events
|
||||
type Gui struct {
|
||||
g *gocui.Gui
|
||||
|
|
@ -62,7 +59,7 @@ type Gui struct {
|
|||
SubProcess *exec.Cmd
|
||||
State guiState
|
||||
Config *config.AppConfig
|
||||
Tr *i18n.Localizer
|
||||
Tr i18n.TranslationSet
|
||||
Errors SentinelErrors
|
||||
statusManager *statusManager
|
||||
waitForIntro sync.WaitGroup
|
||||
|
|
@ -111,7 +108,7 @@ type guiState struct {
|
|||
}
|
||||
|
||||
// NewGui builds a new gui handler
|
||||
func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config *config.AppConfig, errorChan chan error) (*Gui, error) {
|
||||
func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*Gui, error) {
|
||||
|
||||
initialState := guiState{
|
||||
PreviousView: "services",
|
||||
|
|
@ -172,7 +169,7 @@ func (gui *Gui) loadNewDirectory() error {
|
|||
}
|
||||
|
||||
func (gui *Gui) promptAnonymousReporting() error {
|
||||
return gui.createConfirmationPanel(gui.g, nil, gui.Tr.SLocalize("AnonymousReportingTitle"), gui.Tr.SLocalize("AnonymousReportingPrompt"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createConfirmationPanel(gui.g, nil, gui.Tr.AnonymousReportingTitle, gui.Tr.AnonymousReportingPrompt, func(g *gocui.Gui, v *gocui.View) error {
|
||||
gui.waitForIntro.Done()
|
||||
return gui.Config.WriteToUserConfig(func(userConfig *config.UserConfig) error {
|
||||
userConfig.Reporting = "on"
|
||||
|
|
@ -197,10 +194,10 @@ func (gui *Gui) renderAppStatus() error {
|
|||
|
||||
func (gui *Gui) renderGlobalOptions() error {
|
||||
return gui.renderOptionsMap(map[string]string{
|
||||
"PgUp/PgDn": gui.Tr.SLocalize("scroll"),
|
||||
"← → ↑ ↓": gui.Tr.SLocalize("navigate"),
|
||||
"esc/q": gui.Tr.SLocalize("close"),
|
||||
"x": gui.Tr.SLocalize("menu"),
|
||||
"PgUp/PgDn": gui.Tr.Scroll,
|
||||
"← → ↑ ↓": gui.Tr.Navigate,
|
||||
"esc/q": gui.Tr.Close,
|
||||
"x": gui.Tr.Menu,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +275,7 @@ func (gui *Gui) reRenderMain() error {
|
|||
|
||||
func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error {
|
||||
if gui.Config.UserConfig.ConfirmOnQuit {
|
||||
return gui.createConfirmationPanel(g, v, "", gui.Tr.SLocalize("ConfirmQuit"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createConfirmationPanel(g, v, "", gui.Tr.ConfirmQuit, func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}, nil)
|
||||
}
|
||||
|
|
@ -291,7 +288,7 @@ func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
cx, _ := v.Cursor()
|
||||
if cx > len(gui.Tr.SLocalize("Donate")) {
|
||||
if cx > len(gui.Tr.Donate) {
|
||||
return nil
|
||||
}
|
||||
return gui.OSCommand.OpenLink("https://donorbox.org/lazydocker")
|
||||
|
|
@ -327,7 +324,7 @@ func (gui *Gui) runSyncOrAsyncCommand(sub *exec.Cmd, err error) (bool, error) {
|
|||
}
|
||||
|
||||
func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createPromptPanel(g, v, gui.Tr.CustomCommandTitle, func(g *gocui.Gui, v *gocui.View) error {
|
||||
command := gui.trimmedContent(v)
|
||||
gui.SubProcess = gui.OSCommand.RunCustomCommand(command)
|
||||
return gui.Errors.ErrSubProcess
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (gui *Gui) handleImageSelect(g *gocui.Gui, v *gocui.View) error {
|
|||
if err != gui.Errors.ErrNoImages {
|
||||
return err
|
||||
}
|
||||
return gui.renderString(g, "main", gui.Tr.SLocalize("NoImages"))
|
||||
return gui.renderString(g, "main", gui.Tr.NoImages)
|
||||
}
|
||||
|
||||
key := Image.ID + "-" + gui.getImageContexts()[gui.State.Panels.Images.ContextIndex]
|
||||
|
|
@ -238,19 +238,19 @@ func (gui *Gui) handleImagesRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
options := []*removeImageOption{
|
||||
{
|
||||
description: gui.Tr.SLocalize("remove"),
|
||||
description: gui.Tr.Remove,
|
||||
command: "docker image rm " + Image.ID[1:20],
|
||||
configOptions: types.ImageRemoveOptions{PruneChildren: true},
|
||||
runCommand: true,
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("removeWithoutPrune"),
|
||||
description: gui.Tr.RemoveWithoutPrune,
|
||||
command: "docker image rm --no-prune " + Image.ID[1:20],
|
||||
configOptions: types.ImageRemoveOptions{PruneChildren: false},
|
||||
runCommand: true,
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("cancel"),
|
||||
description: gui.Tr.Cancel,
|
||||
runCommand: false,
|
||||
},
|
||||
}
|
||||
|
|
@ -271,8 +271,8 @@ func (gui *Gui) handleImagesRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
func (gui *Gui) handlePruneImages(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("confirmPruneImages"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("PruningStatus"), func() error {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.Confirm, gui.Tr.ConfirmPruneImages, func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.PruningStatus, func() error {
|
||||
err := gui.DockerCommand.PruneImages()
|
||||
if err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
|
|
|
|||
|
|
@ -124,14 +124,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Key: 'e',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleEditConfig,
|
||||
Description: gui.Tr.SLocalize("EditConfig"),
|
||||
Description: gui.Tr.EditConfig,
|
||||
},
|
||||
{
|
||||
ViewName: "status",
|
||||
Key: 'o',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleOpenConfig,
|
||||
Description: gui.Tr.SLocalize("OpenConfig"),
|
||||
Description: gui.Tr.OpenConfig,
|
||||
},
|
||||
{
|
||||
ViewName: "menu",
|
||||
|
|
@ -156,119 +156,119 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Key: '[',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainersPrevContext,
|
||||
Description: gui.Tr.SLocalize("previousContext"),
|
||||
Description: gui.Tr.PreviousContext,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: ']',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainersNextContext,
|
||||
Description: gui.Tr.SLocalize("nextContext"),
|
||||
Description: gui.Tr.NextContext,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 'd',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainersRemoveMenu,
|
||||
Description: gui.Tr.SLocalize("remove"),
|
||||
Description: gui.Tr.Remove,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 's',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainerStop,
|
||||
Description: gui.Tr.SLocalize("stop"),
|
||||
Description: gui.Tr.Stop,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 'r',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainerRestart,
|
||||
Description: gui.Tr.SLocalize("restart"),
|
||||
Description: gui.Tr.Restart,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 'a',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainerAttach,
|
||||
Description: gui.Tr.SLocalize("attach"),
|
||||
Description: gui.Tr.Attach,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'd',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceRemoveMenu,
|
||||
Description: gui.Tr.SLocalize("removeService"),
|
||||
Description: gui.Tr.RemoveService,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 's',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceStop,
|
||||
Description: gui.Tr.SLocalize("stop"),
|
||||
Description: gui.Tr.Stop,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'r',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceRestart,
|
||||
Description: gui.Tr.SLocalize("restart"),
|
||||
Description: gui.Tr.Restart,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'a',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceAttach,
|
||||
Description: gui.Tr.SLocalize("attach"),
|
||||
Description: gui.Tr.Attach,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'm',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceViewLogs,
|
||||
Description: gui.Tr.SLocalize("viewLogs"),
|
||||
Description: gui.Tr.ViewLogs,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: '[',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServicesPrevContext,
|
||||
Description: gui.Tr.SLocalize("previousContext"),
|
||||
Description: gui.Tr.PreviousContext,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: ']',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServicesNextContext,
|
||||
Description: gui.Tr.SLocalize("nextContext"),
|
||||
Description: gui.Tr.NextContext,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: '[',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleImagesPrevContext,
|
||||
Description: gui.Tr.SLocalize("previousContext"),
|
||||
Description: gui.Tr.PreviousContext,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: ']',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleImagesNextContext,
|
||||
Description: gui.Tr.SLocalize("nextContext"),
|
||||
Description: gui.Tr.NextContext,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: 'd',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleImagesRemoveMenu,
|
||||
Description: gui.Tr.SLocalize("removeImage"),
|
||||
Description: gui.Tr.RemoveImage,
|
||||
},
|
||||
{
|
||||
ViewName: "images",
|
||||
Key: 'D',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handlePruneImages,
|
||||
Description: gui.Tr.SLocalize("pruneImages"),
|
||||
Description: gui.Tr.PruneImages,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
v.Title = gui.Tr.SLocalize("NotEnoughSpace")
|
||||
v.Title = gui.Tr.NotEnoughSpace
|
||||
v.Wrap = true
|
||||
_, _ = g.SetViewOnTop("limit")
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
v.Title = gui.Tr.SLocalize("StatusTitle")
|
||||
v.Title = gui.Tr.StatusTitle
|
||||
v.FgColor = gocui.ColorWhite
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
return err
|
||||
}
|
||||
servicesView.Highlight = true
|
||||
servicesView.Title = gui.Tr.SLocalize("ServicesTitle")
|
||||
servicesView.Title = gui.Tr.ServicesTitle
|
||||
servicesView.FgColor = gocui.ColorWhite
|
||||
|
||||
gui.focusPoint(0, gui.State.Panels.Services.SelectedLine, len(gui.DockerCommand.Services), servicesView)
|
||||
|
|
@ -164,7 +164,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
return err
|
||||
}
|
||||
containersView.Highlight = true
|
||||
containersView.Title = gui.Tr.SLocalize("ContainersTitle")
|
||||
containersView.Title = gui.Tr.ContainersTitle
|
||||
containersView.FgColor = gocui.ColorWhite
|
||||
|
||||
gui.focusPoint(0, gui.State.Panels.Containers.SelectedLine, len(gui.DockerCommand.Containers), containersView)
|
||||
|
|
@ -176,7 +176,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
|||
return err
|
||||
}
|
||||
imagesView.Highlight = true
|
||||
imagesView.Title = gui.Tr.SLocalize("ImagesTitle")
|
||||
imagesView.Title = gui.Tr.ImagesTitle
|
||||
imagesView.FgColor = gocui.ColorWhite
|
||||
|
||||
gui.focusPoint(0, gui.State.Panels.Images.SelectedLine, len(gui.DockerCommand.Images), imagesView)
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ func (gui *Gui) handleMenuPrevLine(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
func (gui *Gui) renderMenuOptions() error {
|
||||
optionsMap := map[string]string{
|
||||
"esc/q": gui.Tr.SLocalize("close"),
|
||||
"↑ ↓": gui.Tr.SLocalize("navigate"),
|
||||
"space": gui.Tr.SLocalize("execute"),
|
||||
"esc/q": gui.Tr.Close,
|
||||
"↑ ↓": gui.Tr.Navigate,
|
||||
"space": gui.Tr.Execute,
|
||||
}
|
||||
return gui.renderOptionsMap(optionsMap)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,5 +49,5 @@ func (gui *Gui) handleCreateOptionsMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
return bindings[index].Handler(g, v)
|
||||
}
|
||||
|
||||
return gui.createMenu(strings.Title(gui.Tr.SLocalize("menu")), bindings, len(bindings), handleMenuPress)
|
||||
return gui.createMenu(strings.Title(gui.Tr.Menu), bindings, len(bindings), handleMenuPress)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,15 +203,15 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
options := []*removeServiceOption{
|
||||
{
|
||||
description: gui.Tr.SLocalize("remove"),
|
||||
description: gui.Tr.Remove,
|
||||
command: fmt.Sprintf("%s rm --stop --force %s", composeCommand, service.Name),
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("removeWithVolumes"),
|
||||
description: gui.Tr.RemoveWithVolumes,
|
||||
command: fmt.Sprintf("%s rm --stop --force -v %s", composeCommand, service.Name),
|
||||
},
|
||||
{
|
||||
description: gui.Tr.SLocalize("cancel"),
|
||||
description: gui.Tr.Cancel,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
if options[index].command == "" {
|
||||
return nil
|
||||
}
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.RemovingStatus, func() error {
|
||||
if err := gui.OSCommand.RunCommand(options[index].command); err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
|
@ -237,8 +237,8 @@ func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("StopService"), func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("StoppingStatus"), func() error {
|
||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.Confirm, gui.Tr.StopService, func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error {
|
||||
if err := service.Stop(); err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RestartingStatus"), func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.RestartingStatus, func() error {
|
||||
if err := service.Restart(); err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (gui *Gui) runCommand() error {
|
|||
gui.SubProcess.Stdin = nil
|
||||
gui.SubProcess = nil
|
||||
|
||||
fmt.Fprintf(os.Stdout, "\n%s", utils.ColoredString(gui.Tr.SLocalize("pressEnterToReturn"), color.FgGreen))
|
||||
fmt.Fprintf(os.Stdout, "\n%s", utils.ColoredString(gui.Tr.PressEnterToReturn, color.FgGreen))
|
||||
|
||||
fmt.Scanln() // wait for enter press
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
|
|||
v.Highlight = false
|
||||
return nil
|
||||
default:
|
||||
panic(gui.Tr.SLocalize("NoViewMachingNewLineFocusedSwitchStatement"))
|
||||
panic(gui.Tr.NoViewMachingNewLineFocusedSwitchStatement)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,6 @@ func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error {
|
|||
if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
|
||||
return nil
|
||||
}
|
||||
gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
|
||||
_, err := g.SetView(v.Name(), x0, y0, x1, y1, 0)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ type TranslationSet struct {
|
|||
Execute string
|
||||
Scroll string
|
||||
Close string
|
||||
Error string
|
||||
ResizingPopupPanel string
|
||||
ErrorTitle string
|
||||
RunningSubprocess string
|
||||
NoViewMachingNewLineFocusedSwitchStatement string
|
||||
OpenConfig string
|
||||
|
|
@ -23,7 +22,7 @@ type TranslationSet struct {
|
|||
ErrorOccurred string
|
||||
Donate string
|
||||
Cancel string
|
||||
CustomCommand string
|
||||
CustomCommandTitle string
|
||||
Remove string
|
||||
RemoveWithVolumes string
|
||||
MustForceToRemoveContainer string
|
||||
|
|
@ -55,52 +54,58 @@ type TranslationSet struct {
|
|||
|
||||
func englishSet() TranslationSet {
|
||||
return TranslationSet{
|
||||
NotEnoughSpace: "Not enough space to render panels",
|
||||
StatusTitle: "Status",
|
||||
Navigate: "navigate",
|
||||
Menu: "menu",
|
||||
Execute: "execute",
|
||||
Scroll: "scroll",
|
||||
Close: "close",
|
||||
Error: "Error",
|
||||
ResizingPopupPanel: "resizing popup panel",
|
||||
RunningSubprocess: "running subprocess",
|
||||
PruningStatus: "pruning",
|
||||
RemovingStatus: "removing",
|
||||
RestartingStatus: "restarting",
|
||||
StoppingStatus: "stopping",
|
||||
|
||||
RunningSubprocess: "running subprocess",
|
||||
NoViewMachingNewLineFocusedSwitchStatement: "No view matching newLineFocused switch statement",
|
||||
OpenConfig: "open config container",
|
||||
EditConfig: "edit config container",
|
||||
AnonymousReportingTitle: "Help make lazydocker better",
|
||||
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker? (enter/esc)",
|
||||
|
||||
ErrorOccurred: "An error occurred! Please create an issue at https://github.com/jesseduffield/lazydocker/issues",
|
||||
Donate: "Donate",
|
||||
Confirm: "Confirm",
|
||||
|
||||
Navigate: "navigate",
|
||||
Execute: "execute",
|
||||
Close: "close",
|
||||
Menu: "menu",
|
||||
Scroll: "scroll",
|
||||
OpenConfig: "open config container",
|
||||
EditConfig: "edit config container",
|
||||
Cancel: "cancel",
|
||||
Remove: "remove",
|
||||
RemoveWithVolumes: "remove with volumes",
|
||||
RemoveService: "remove containers",
|
||||
Stop: "stop",
|
||||
Restart: "restart",
|
||||
PreviousContext: "previous context",
|
||||
NextContext: "next context",
|
||||
Attach: "attach",
|
||||
ViewLogs: "view logs",
|
||||
RemoveImage: "remove image",
|
||||
RemoveWithoutPrune: "remove without deleting untagged parents",
|
||||
PruneImages: "prune unused images",
|
||||
|
||||
AnonymousReportingTitle: "Help make lazydocker better",
|
||||
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker? (enter/esc)",
|
||||
|
||||
StatusTitle: "Status",
|
||||
ServicesTitle: "Services",
|
||||
ContainersTitle: "Containers",
|
||||
ImagesTitle: "Images",
|
||||
CustomCommandTitle: "Custom Command:",
|
||||
ErrorTitle: "Error",
|
||||
|
||||
NoContainers: "No containers",
|
||||
NoImages: "No images",
|
||||
|
||||
ConfirmQuit: "Are you sure you want to quit?",
|
||||
ErrorOccurred: "An error occurred! Please create an issue at https://github.com/jesseduffield/lazydocker/issues",
|
||||
Donate: "Donate",
|
||||
Cancel: "cancel",
|
||||
CustomCommand: "Custom Command:",
|
||||
Remove: "remove",
|
||||
RemoveWithVolumes: "remove with volumes",
|
||||
MustForceToRemoveContainer: "You cannot remove a running container unless you force it. Do you want to force it?",
|
||||
Confirm: "Confirm",
|
||||
StopContainer: "Are you sure you want to stop this container?",
|
||||
RestartingStatus: "restarting",
|
||||
StoppingStatus: "stopping",
|
||||
RemovingStatus: "removing",
|
||||
RemoveService: "remove containers",
|
||||
Stop: "stop",
|
||||
Restart: "restart",
|
||||
PreviousContext: "previous context",
|
||||
NextContext: "next context",
|
||||
Attach: "attach",
|
||||
ViewLogs: "view logs",
|
||||
ServicesTitle: "Services",
|
||||
ContainersTitle: "Containers",
|
||||
ImagesTitle: "Images",
|
||||
NoContainers: "No containers",
|
||||
NoImages: "No images",
|
||||
RemoveImage: "remove image",
|
||||
RemoveWithoutPrune: "remove without deleting untagged parents",
|
||||
PruneImages: "prune unused images",
|
||||
NotEnoughSpace: "Not enough space to render panels",
|
||||
ConfirmPruneImages: "Are you sure you want to prune all unused images?",
|
||||
PruningStatus: "pruning",
|
||||
StopService: "Are you sure you want to stop this service's containers? (enter/esc)",
|
||||
StopContainer: "Are you sure you want to stop this container?",
|
||||
PressEnterToReturn: "Press enter to return to lazydocker",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func writeString(file *os.File, str string) {
|
|||
|
||||
func localisedTitle(mApp *app.App, str string) string {
|
||||
viewTitle := strings.Title(str) + "Title"
|
||||
return mApp.Tr.SLocalize(viewTitle)
|
||||
return mApp.Tr.ViewTitle // FIXME: this used to be dynamic but we can't make this dynamic again without reflection since we're now using a struct of translation strings
|
||||
}
|
||||
|
||||
func formatTitle(title string) string {
|
||||
|
|
@ -116,7 +116,7 @@ func addBinding(title string, bindingSections []*bindingSection, binding *gui.Bi
|
|||
}
|
||||
|
||||
func formatSections(mApp *app.App, bindingSections []*bindingSection) string {
|
||||
content := fmt.Sprintf("# Lazydocker %s\n", mApp.Tr.SLocalize("menu"))
|
||||
content := fmt.Sprintf("# Lazydocker %s\n", mApp.Tr.Menu)
|
||||
|
||||
for _, section := range bindingSections {
|
||||
content += formatTitle(section.title)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue