pull/1/head
Jesse Duffield 5 years ago
parent 53844b2d7b
commit 5d40c084a5

@ -0,0 +1,62 @@
ids = %w[
AnonymousReportingPrompt
AnonymousReportingTitle
attach
cancel
close
Confirm
confirmPruneImages
ConfirmQuit
ContainersTitle
CustomCommand
Donate
EditConfig
Error
ErrorOccurred
execute
ImagesTitle
menu
mustForceToRemoveContainer
navigate
nextContext
NoContainers
NoImages
NotEnoughSpace
NoViewMachingNewLineFocusedSwitchStatement
OpenConfig
pressEnterToReturn
previousContext
pruneImages
PruningStatus
remove
removeImage
removeService
removeWithoutPrune
removeWithVolumes
RemovingStatus
resizingPopupPanel
restart
RestartingStatus
RunningSubprocess
scroll
ServicesTitle
StatusTitle
stop
StopContainer
StoppingStatus
StopService
viewLogs
]
f = File.read('pkg/i18n/english.go')
f.lines.each_with_index do |line, index|
if line[/ID:/]
stripped = line.strip.gsub(/ID: *"/, '",').gsub('",', '')
if ids.include?(stripped)
key = stripped[0].upcase + stripped[1..-1]
value = f.lines[index+1].strip.gsub(/Other: *"/, '').gsub('",', '')
puts "#{key}: \"#{value}\","
end
end
end

@ -33,7 +33,7 @@ func NewApp(config *config.AppConfig) (*App, error) {
}
var err error
app.Log = log.NewLogger(config, "23432119147a4367abf7c0de2aa99a2d")
app.Tr = i18n.NewLocalizer(app.Log)
app.Tr := i18n.NewTranslationSet(logger)
app.OSCommand = commands.NewOSCommand(app.Log, config)
// here is the place to make use of the docker-compose.yml file in the current directory

@ -1,17 +1,5 @@
package i18n
import (
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
// addDutch will add all dutch translations
func addDutch(i18nObject *i18n.Bundle) error {
// add the translations
return i18nObject.AddMessages(language.Dutch,
&i18n.Message{
ID: "NotEnoughSpace",
Other: "Niet genoeg ruimte om de panelen te renderen",
})
func dutchSet() TranslationSet {
return TranslationSet{}
}

@ -1,876 +1,106 @@
/*
Todo list when making a new translation
- Copy this container and rename it to the language you want to translate to like someLanguage.go
- Change the addEnglish() name to the language you want to translate to like addSomeLanguage()
- change the first function argument of i18nObject.AddMessages( to the language you want to translate to like language.SomeLanguage
- Remove this todo and the about section
*/
package i18n
import (
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
func addEnglish(i18nObject *i18n.Bundle) error {
return i18nObject.AddMessages(language.English,
&i18n.Message{
ID: "NotEnoughSpace",
Other: "Not enough space to render panels",
}, &i18n.Message{
ID: "DiffTitle",
Other: "Diff",
}, &i18n.Message{
ID: "LogTitle",
Other: "Log",
}, &i18n.Message{
ID: "BranchesTitle",
Other: "Branches",
}, &i18n.Message{
ID: "CommitsTitle",
Other: "Commits",
}, &i18n.Message{
ID: "CommitsDiffTitle",
Other: "Commits (specific diff mode)",
}, &i18n.Message{
ID: "CommitsDiff",
Other: "select commit to diff with another commit",
}, &i18n.Message{
ID: "StashTitle",
Other: "Stash",
}, &i18n.Message{
ID: "StagingMainTitle",
Other: `Stage Lines/Hunks`,
}, &i18n.Message{
ID: "MergingMainTitle",
Other: "Resolve merge conflicts",
}, &i18n.Message{
ID: "MainTitle",
Other: "Main",
}, &i18n.Message{
ID: "StagingTitle",
Other: "Staging",
}, &i18n.Message{
ID: "MergingTitle",
Other: "Merging",
}, &i18n.Message{
ID: "NormalTitle",
Other: "Normal",
}, &i18n.Message{
ID: "CommitMessage",
Other: "Commit message",
}, &i18n.Message{
ID: "CredentialsUsername",
Other: "Username",
}, &i18n.Message{
ID: "CredentialsPassword",
Other: "Password",
}, &i18n.Message{
ID: "PassUnameWrong",
Other: "Password and/or username wrong",
}, &i18n.Message{
ID: "CommitChanges",
Other: "commit changes",
}, &i18n.Message{
ID: "AmendLastCommit",
Other: "amend last commit",
}, &i18n.Message{
ID: "SureToAmend",
Other: "Are you sure you want to amend last commit? Afterwards, you can change commit message from the commits panel.",
}, &i18n.Message{
ID: "NoCommitToAmend",
Other: "There's no commit to amend.",
}, &i18n.Message{
ID: "CommitChangesWithEditor",
Other: "commit changes using git editor",
}, &i18n.Message{
ID: "StatusTitle",
Other: "Status",
}, &i18n.Message{
ID: "GlobalTitle",
Other: "Global",
}, &i18n.Message{
ID: "navigate",
Other: "navigate",
}, &i18n.Message{
ID: "menu",
Other: "menu",
}, &i18n.Message{
ID: "execute",
Other: "execute",
}, &i18n.Message{
ID: "stashContainers",
Other: "stash containers",
}, &i18n.Message{
ID: "open",
Other: "open",
}, &i18n.Message{
ID: "ignore",
Other: "ignore",
}, &i18n.Message{
ID: "delete",
Other: "delete",
}, &i18n.Message{
ID: "toggleStaged",
Other: "toggle staged",
}, &i18n.Message{
ID: "toggleStagedAll",
Other: "stage/unstage all",
}, &i18n.Message{
ID: "refresh",
Other: "refresh",
}, &i18n.Message{
ID: "push",
Other: "push",
}, &i18n.Message{
ID: "pull",
Other: "pull",
}, &i18n.Message{
ID: "addPatch",
Other: "add patch",
}, &i18n.Message{
ID: "edit",
Other: "edit",
}, &i18n.Message{
ID: "scroll",
Other: "scroll",
}, &i18n.Message{
ID: "abortMerge",
Other: "abort merge",
}, &i18n.Message{
ID: "resolveMergeConflicts",
Other: "resolve merge conflicts",
}, &i18n.Message{
ID: "checkout",
Other: "checkout",
}, &i18n.Message{
ID: "ContainerHasNoUnstagedChanges",
Other: "Container has no unstaged changes to add",
}, &i18n.Message{
ID: "CannotGitAdd",
Other: "Cannot git add --patch untracked containers",
}, &i18n.Message{
ID: "CantIgnoreTrackContainers",
Other: "Cannot ignore tracked containers",
}, &i18n.Message{
ID: "NoStagedContainersToCommit",
Other: "There are no staged containers to commit",
}, &i18n.Message{
ID: "NoContainersDisplay",
Other: "No container to display",
}, &i18n.Message{
ID: "NotAContainer",
Other: "Not a container",
}, &i18n.Message{
ID: "PullWait",
Other: "Pulling...",
}, &i18n.Message{
ID: "PushWait",
Other: "Pushing...",
}, &i18n.Message{
ID: "FetchWait",
Other: "Fetching...",
}, &i18n.Message{
ID: "ContainerNoMergeCons",
Other: "This container has no inline merge conflicts",
}, &i18n.Message{
ID: "softReset",
Other: "soft reset",
}, &i18n.Message{
ID: "SureTo",
Other: "Are you sure you want to {{.deleteVerb}} {{.containerName}} (you will lose your changes)?",
}, &i18n.Message{
ID: "AlreadyCheckedOutBranch",
Other: "You have already checked out this branch",
}, &i18n.Message{
ID: "SureForceCheckout",
Other: "Are you sure you want force checkout? You will lose all local changes",
}, &i18n.Message{
ID: "ForceCheckoutBranch",
Other: "Force Checkout Branch",
}, &i18n.Message{
ID: "BranchName",
Other: "Branch name",
}, &i18n.Message{
ID: "NewBranchNameBranchOff",
Other: "New Branch Name (Branch is off of {{.branchName}})",
}, &i18n.Message{
ID: "CantDeleteCheckOutBranch",
Other: "You cannot delete the checked out branch!",
}, &i18n.Message{
ID: "DeleteBranch",
Other: "Delete Branch",
}, &i18n.Message{
ID: "DeleteBranchMessage",
Other: "Are you sure you want to delete the branch {{.selectedBranchName}}?",
}, &i18n.Message{
ID: "ForceDeleteBranchMessage",
Other: "{{.selectedBranchName}} is not fully merged. Are you sure you want to delete it?",
}, &i18n.Message{
ID: "rebaseBranch",
Other: "rebase branch",
}, &i18n.Message{
ID: "CantRebaseOntoSelf",
Other: "You cannot rebase a branch onto itself",
}, &i18n.Message{
ID: "CantMergeBranchIntoItself",
Other: "You cannot merge a branch into itself",
}, &i18n.Message{
ID: "forceCheckout",
Other: "force checkout",
}, &i18n.Message{
ID: "merge",
Other: "merge",
}, &i18n.Message{
ID: "checkoutByName",
Other: "checkout by name",
}, &i18n.Message{
ID: "newBranch",
Other: "new branch",
}, &i18n.Message{
ID: "deleteBranch",
Other: "delete branch",
}, &i18n.Message{
ID: "forceDeleteBranch",
Other: "delete branch (force)",
}, &i18n.Message{
ID: "NoBranchesThisRepo",
Other: "No branches for this repo",
}, &i18n.Message{
ID: "NoTrackingThisBranch",
Other: "There is no tracking for this branch",
}, &i18n.Message{
ID: "CommitWithoutMessageErr",
Other: "You cannot commit without a commit message",
}, &i18n.Message{
ID: "CloseConfirm",
Other: "{{.keyBindClose}}: close, {{.keyBindConfirm}}: confirm",
}, &i18n.Message{
ID: "close",
Other: "close",
}, &i18n.Message{
ID: "SureResetThisCommit",
Other: "Are you sure you want to reset to this commit?",
}, &i18n.Message{
ID: "ResetToCommit",
Other: "Reset To Commit",
}, &i18n.Message{
ID: "squashDown",
Other: "squash down",
}, &i18n.Message{
ID: "rename",
Other: "rename",
}, &i18n.Message{
ID: "resetToThisCommit",
Other: "reset to this commit",
}, &i18n.Message{
ID: "fixupCommit",
Other: "fixup commit",
}, &i18n.Message{
ID: "NoCommitsThisBranch",
Other: "No commits for this branch",
}, &i18n.Message{
ID: "OnlySquashTopmostCommit",
Other: "Can only squash topmost commit",
}, &i18n.Message{
ID: "YouNoCommitsToSquash",
Other: "You have no commits to squash with",
}, &i18n.Message{
ID: "CantFixupWhileUnstagedChanges",
Other: "Can't fixup while there are unstaged changes",
}, &i18n.Message{
ID: "Fixup",
Other: "Fixup",
}, &i18n.Message{
ID: "SureFixupThisCommit",
Other: "Are you sure you want to 'fixup' this commit? It will be merged into the commit below",
}, &i18n.Message{
ID: "SureSquashThisCommit",
Other: "Are you sure you want to squash this commit into the commit below?",
}, &i18n.Message{
ID: "Squash",
Other: "Squash",
}, &i18n.Message{
ID: "pickCommit",
Other: "pick commit (when mid-rebase)",
}, &i18n.Message{
ID: "revertCommit",
Other: "revert commit",
}, &i18n.Message{
ID: "OnlyRenameTopCommit",
Other: "Can only reword topmost commit from within lazydocker. Use shift+R instead",
}, &i18n.Message{
ID: "renameCommit",
Other: "reword commit",
}, &i18n.Message{
ID: "deleteCommit",
Other: "delete commit",
}, &i18n.Message{
ID: "moveDownCommit",
Other: "move commit down one",
}, &i18n.Message{
ID: "moveUpCommit",
Other: "move commit up one",
}, &i18n.Message{
ID: "editCommit",
Other: "edit commit",
}, &i18n.Message{
ID: "amendToCommit",
Other: "amend commit with staged changes",
}, &i18n.Message{
ID: "renameCommitEditor",
Other: "rename commit with editor",
}, &i18n.Message{
ID: "PotentialErrInGetselectedCommit",
Other: "potential error in getSelected Commit (mismatched ui and state)",
}, &i18n.Message{
ID: "NoCommitsThisBranch",
Other: "No commits for this branch",
}, &i18n.Message{
ID: "Error",
Other: "Error",
}, &i18n.Message{
ID: "resizingPopupPanel",
Other: "resizing popup panel",
}, &i18n.Message{
ID: "RunningSubprocess",
Other: "running subprocess",
}, &i18n.Message{
ID: "selectHunk",
Other: "select hunk",
}, &i18n.Message{
ID: "navigateConflicts",
Other: "navigate conflicts",
}, &i18n.Message{
ID: "pickHunk",
Other: "pick hunk",
}, &i18n.Message{
ID: "pickBothHunks",
Other: "pick both hunks",
}, &i18n.Message{
ID: "undo",
Other: "undo",
}, &i18n.Message{
ID: "pop",
Other: "pop",
}, &i18n.Message{
ID: "drop",
Other: "drop",
}, &i18n.Message{
ID: "apply",
Other: "apply",
}, &i18n.Message{
ID: "NoStashEntries",
Other: "No stash entries",
}, &i18n.Message{
ID: "StashDrop",
Other: "Stash drop",
}, &i18n.Message{
ID: "SureDropStashEntry",
Other: "Are you sure you want to drop this stash entry?",
}, &i18n.Message{
ID: "NoStashTo",
Other: "No stash to {{.method}}",
}, &i18n.Message{
ID: "NoTrackedStagedContainersStash",
Other: "You have no tracked/staged containers to stash",
}, &i18n.Message{
ID: "StashChanges",
Other: "Stash changes",
}, &i18n.Message{
ID: "IssntListOfViews",
Other: "{{.name}} is not in the list of views",
}, &i18n.Message{
ID: "NoViewMachingNewLineFocusedSwitchStatement",
Other: "No view matching newLineFocused switch statement",
}, &i18n.Message{
ID: "newFocusedViewIs",
Other: "new focused view is {{.newFocusedView}}",
}, &i18n.Message{
ID: "CantCloseConfirmationPrompt",
Other: "Could not close confirmation prompt: {{.error}}",
}, &i18n.Message{
ID: "NoChangedContainers",
Other: "No changed containers",
}, &i18n.Message{
ID: "MergeAborted",
Other: "Merge aborted",
}, &i18n.Message{
ID: "OpenConfig",
Other: "open config container",
}, &i18n.Message{
ID: "EditConfig",
Other: "edit config container",
}, &i18n.Message{
ID: "ForcePush",
Other: "Force push",
}, &i18n.Message{
ID: "ForcePushPrompt",
Other: "Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.",
}, &i18n.Message{
ID: "checkForUpdate",
Other: "check for update",
}, &i18n.Message{
ID: "CheckingForUpdates",
Other: "Checking for updates...",
}, &i18n.Message{
ID: "OnLatestVersionErr",
Other: "You already have the latest version",
}, &i18n.Message{
ID: "MajorVersionErr",
Other: "New version ({{.newVersion}}) has non-backwards compatible changes compared to the current version ({{.currentVersion}})",
}, &i18n.Message{
ID: "CouldNotFindBinaryErr",
Other: "Could not find any binary at {{.url}}",
}, &i18n.Message{
ID: "AnonymousReportingTitle",
Other: "Help make lazydocker better",
}, &i18n.Message{
ID: "AnonymousReportingPrompt",
Other: "Would you like to enable anonymous reporting data to help improve lazydocker? (enter/esc)",
}, &i18n.Message{
ID: "GitconfigParseErr",
Other: `Gogit failed to parse your gitconfig container due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
}, &i18n.Message{
ID: "editContainer",
Other: `edit container`,
}, &i18n.Message{
ID: "openContainer",
Other: `open container`,
}, &i18n.Message{
ID: "ignoreContainer",
Other: `add to .gitignore`,
}, &i18n.Message{
ID: "refreshContainersAndServices",
Other: `refresh containers`,
}, &i18n.Message{
ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`,
}, &i18n.Message{
ID: "ConfirmQuit",
Other: `Are you sure you want to quit?`,
}, &i18n.Message{
ID: "SwitchRepo",
Other: `switch to a recent repo`,
}, &i18n.Message{
ID: "UnsupportedGitService",
Other: `Unsupported git service`,
}, &i18n.Message{
ID: "createPullRequest",
Other: `create pull request`,
}, &i18n.Message{
ID: "NoBranchOnRemote",
Other: `This branch doesn't exist on remote. You need to push it to remote first.`,
}, &i18n.Message{
ID: "fetch",
Other: `fetch`,
}, &i18n.Message{
ID: "NoAutomaticGitFetchTitle",
Other: `No automatic git fetch`,
}, &i18n.Message{
ID: "NoAutomaticGitFetchBody",
Other: `Lazydocker can't use "git fetch" in a private repo; use 'f' in the containers panel to run "git fetch" manually`,
}, &i18n.Message{
ID: "StageLines",
Other: `stage individual hunks/lines`,
}, &i18n.Message{
ID: "ContainerStagingRequirements",
Other: `Can only stage individual lines for tracked containers with unstaged changes`,
}, &i18n.Message{
ID: "StageHunk",
Other: `stage hunk`,
}, &i18n.Message{
ID: "StageLine",
Other: `stage line`,
}, &i18n.Message{
ID: "EscapeStaging",
Other: `return to containers panel`,
}, &i18n.Message{
ID: "CantFindHunks",
Other: `Could not find any hunks in this patch`,
}, &i18n.Message{
ID: "CantFindHunk",
Other: `Could not find hunk`,
}, &i18n.Message{
ID: "FastForward",
Other: `fast-forward this branch from its upstream`,
}, &i18n.Message{
ID: "Fetching",
Other: "fetching and fast-forwarding {{.from}} -> {{.to}} ...",
}, &i18n.Message{
ID: "FoundConflicts",
Other: "Conflicts! To abort press 'esc', otherwise press 'enter'",
}, &i18n.Message{
ID: "FoundConflictsTitle",
Other: "Auto-merge failed",
}, &i18n.Message{
ID: "Undo",
Other: "undo",
}, &i18n.Message{
ID: "PickHunk",
Other: "pick hunk",
}, &i18n.Message{
ID: "PickBothHunks",
Other: "pick both hunks",
}, &i18n.Message{
ID: "ViewMergeRebaseOptions",
Other: "view merge/rebase options",
}, &i18n.Message{
ID: "NotMergingOrRebasing",
Other: "You are currently neither rebasing nor merging",
}, &i18n.Message{
ID: "RecentRepos",
Other: "recent repositories",
}, &i18n.Message{
ID: "MergeOptionsTitle",
Other: "Merge Options",
}, &i18n.Message{
ID: "RebaseOptionsTitle",
Other: "Rebase Options",
}, &i18n.Message{
ID: "ConflictsResolved",
Other: "all merge conflicts resolved. Continue?",
}, &i18n.Message{
ID: "RebasingTitle",
Other: "Rebasing",
}, &i18n.Message{
ID: "MergingTitle",
Other: "Merging",
}, &i18n.Message{
ID: "ConfirmRebase",
Other: "Are you sure you want to rebase {{.checkedOutBranch}} onto {{.selectedBranch}}?",
}, &i18n.Message{
ID: "ConfirmMerge",
Other: "Are you sure you want to merge {{.selectedBranch}} into {{.checkedOutBranch}}?",
}, &i18n.Message{}, &i18n.Message{
ID: "FwdNoUpstream",
Other: "Cannot fast-forward a branch with no upstream",
}, &i18n.Message{
ID: "FwdCommitsToPush",
Other: "Cannot fast-forward a branch with commits to push",
}, &i18n.Message{
ID: "ErrorOccurred",
Other: "An error occurred! Please create an issue at https://github.com/jesseduffield/lazydocker/issues",
}, &i18n.Message{
ID: "NoRoom",
Other: "Not enough room",
}, &i18n.Message{
ID: "YouAreHere",
Other: "YOU ARE HERE",
}, &i18n.Message{
ID: "rewordNotSupported",
Other: "rewording commits while interactively rebasing is not currently supported",
}, &i18n.Message{
ID: "cherryPickCopy",
Other: "copy commit (cherry-pick)",
}, &i18n.Message{
ID: "cherryPickCopyRange",
Other: "copy commit range (cherry-pick)",
}, &i18n.Message{
ID: "pasteCommits",
Other: "paste commits (cherry-pick)",
}, &i18n.Message{
ID: "SureCherryPick",
Other: "Are you sure you want to cherry-pick the copied commits onto this branch?",
}, &i18n.Message{
ID: "CherryPick",
Other: "Cherry-Pick",
}, &i18n.Message{
ID: "CannotRebaseOntoFirstCommit",
Other: "You cannot interactive rebase onto the first commit",
}, &i18n.Message{
ID: "CannotSquashOntoSecondCommit",
Other: "You cannot squash/fixup onto the second commit",
}, &i18n.Message{
ID: "Donate",
Other: "Donate",
}, &i18n.Message{
ID: "PrevLine",
Other: "select previous line",
}, &i18n.Message{
ID: "NextLine",
Other: "select next line",
}, &i18n.Message{
ID: "PrevHunk",
Other: "select previous hunk",
}, &i18n.Message{
ID: "NextHunk",
Other: "select next hunk",
}, &i18n.Message{
ID: "PrevConflict",
Other: "select previous conflict",
}, &i18n.Message{
ID: "NextConflict",
Other: "select next conflict",
}, &i18n.Message{
ID: "SelectTop",
Other: "select top hunk",
}, &i18n.Message{
ID: "SelectBottom",
Other: "select bottom hunk",
}, &i18n.Message{
ID: "ScrollDown",
Other: "scroll down",
}, &i18n.Message{
ID: "ScrollUp",
Other: "scroll up",
}, &i18n.Message{
ID: "AmendCommitTitle",
Other: "Amend Commit",
}, &i18n.Message{
ID: "AmendCommitPrompt",
Other: "Are you sure you want to amend this commit with your staged containers?",
}, &i18n.Message{
ID: "DeleteCommitTitle",
Other: "Delete Commit",
}, &i18n.Message{
ID: "DeleteCommitPrompt",
Other: "Are you sure you want to delete this commit?",
}, &i18n.Message{
ID: "SquashingStatus",
Other: "squashing",
}, &i18n.Message{
ID: "FixingStatus",
Other: "fixing up",
}, &i18n.Message{
ID: "DeletingStatus",
Other: "deleting",
}, &i18n.Message{
ID: "MovingStatus",
Other: "moving",
}, &i18n.Message{
ID: "RebasingStatus",
Other: "rebasing",
}, &i18n.Message{
ID: "AmendingStatus",
Other: "amending",
}, &i18n.Message{
ID: "CherryPickingStatus",
Other: "cherry-picking",
}, &i18n.Message{
ID: "CommitContainers",
Other: "Commit containers",
}, &i18n.Message{
ID: "viewCommitContainers",
Other: "view commit's containers",
}, &i18n.Message{
ID: "CommitContainersTitle",
Other: "Commit containers",
}, &i18n.Message{
ID: "goBack",
Other: "go back",
}, &i18n.Message{
ID: "NoCommiteContainers",
Other: "No containers for this commit",
}, &i18n.Message{
ID: "checkoutCommitContainer",
Other: "checkout container",
}, &i18n.Message{
ID: "discardOldContainerChange",
Other: "discard this commit's changes to this container",
}, &i18n.Message{
ID: "DiscardContainerChangesTitle",
Other: "Discard container changes",
}, &i18n.Message{
ID: "DiscardContainerChangesPrompt",
Other: "Are you sure you want to discard this commit's changes to this container? If this container was created in this commit, it will be deleted",
}, &i18n.Message{
ID: "DisabledForGPG",
Other: "Feature not available for users using GPG",
}, &i18n.Message{
ID: "CreateRepo",
Other: "Not in a git repository. Create a new git repository? (y/n): ",
}, &i18n.Message{
ID: "AutoStashTitle",
Other: "Autostash?",
}, &i18n.Message{
ID: "AutoStashPrompt",
Other: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)",
}, &i18n.Message{
ID: "StashPrefix",
Other: "Auto-stashing changes for ",
}, &i18n.Message{
ID: "viewDiscardOptions",
Other: "view 'discard changes' options",
}, &i18n.Message{
ID: "cancel",
Other: "cancel",
}, &i18n.Message{
ID: "discardAllChanges",
Other: "discard all changes",
}, &i18n.Message{
ID: "discardUnstagedChanges",
Other: "discard unstaged changes",
}, &i18n.Message{
ID: "discardAllChangesToAllContainers",
Other: "nuke working tree",
}, &i18n.Message{
ID: "discardAnyUnstagedChanges",
Other: "discard unstaged changes",
}, &i18n.Message{
ID: "discardUntrackedContainers",
Other: "discard untracked containers",
}, &i18n.Message{
ID: "hardReset",
Other: "hard reset",
}, &i18n.Message{
ID: "viewResetOptions",
Other: `view reset options`,
}, &i18n.Message{
ID: "createFixupCommit",
Other: `create fixup commit for this commit`,
}, &i18n.Message{
ID: "squashAboveCommits",
Other: `squash above commits`,
}, &i18n.Message{
ID: "SquashAboveCommits",
Other: `Squash above commits`,
}, &i18n.Message{
ID: "SureSquashAboveCommits",
Other: `Are you sure you want to squash all fixup! commits above {{.commit}}?`,
}, &i18n.Message{
ID: "CreateFixupCommit",
Other: `Create fixup commit`,
}, &i18n.Message{
ID: "SureCreateFixupCommit",
Other: `Are you sure you want to create a fixup! commit for commit {{.commit}}?`,
}, &i18n.Message{
ID: "executeCustomCommand",
Other: "execute custom command",
}, &i18n.Message{
ID: "CustomCommand",
Other: "Custom Command:",
}, &i18n.Message{
ID: "commitChangesWithoutHook",
Other: "commit changes without pre-commit hook",
}, &i18n.Message{
ID: "SkipHookPrefixNotConfigured",
Other: "You have not configured a commit message prefix for skipping hooks. Set `git.skipHookPrefix = 'WIP'` in your config",
}, &i18n.Message{
ID: "resetTo",
Other: `reset to`,
},
// TranslationSet is a set of localised strings for a given language
type TranslationSet struct {
AddFavourite string
ErrorMessage string
NotEnoughSpace string
StatusTitle string
Navigate string
Menu string
Execute string
Scroll string
Close string
Error string
ResizingPopupPanel string
RunningSubprocess string
NoViewMachingNewLineFocusedSwitchStatement string
OpenConfig string
EditConfig string
AnonymousReportingTitle string
AnonymousReportingPrompt string
ConfirmQuit string
ErrorOccurred string
Donate string
Cancel string
CustomCommand string
Remove string
RemoveWithVolumes string
MustForceToRemoveContainer string
Confirm string
StopContainer string
RestartingStatus string
StoppingStatus string
RemovingStatus string
RemoveService string
Stop string
Restart string
PreviousContext string
NextContext string
Attach string
ViewLogs string
ServicesTitle string
ContainersTitle string
ImagesTitle string
NoContainers string
NoImages string
RemoveImage string
RemoveWithoutPrune string
PruneImages string
ConfirmPruneImages string
PruningStatus string
StopService string
PressEnterToReturn string
}
// ALL LAZYDOCKER STUFF BELOW:
&i18n.Message{
ID: "remove",
Other: `remove`,
},
&i18n.Message{
ID: "removeWithVolumes",
Other: `remove with volumes`,
},
&i18n.Message{
ID: "mustForceToRemoveContainer",
Other: "You cannot remove a running container unless you force it. Do you want to force it?",
},
&i18n.Message{
ID: "Confirm",
Other: "Confirm",
},
&i18n.Message{
ID: "StopContainer",
Other: "Are you sure you want to stop this container?",
},
&i18n.Message{
ID: "RestartingStatus",
Other: "restarting",
},
&i18n.Message{
ID: "StoppingStatus",
Other: "stopping",
},
&i18n.Message{
ID: "RemovingStatus",
Other: "removing",
},
&i18n.Message{
ID: "remove",
Other: "remove",
},
&i18n.Message{
ID: "removeService",
Other: "remove containers",
},
&i18n.Message{
ID: "stop",
Other: "stop",
},
&i18n.Message{
ID: "restart",
Other: "restart",
},
&i18n.Message{
ID: "previousContext",
Other: "previous context",
},
&i18n.Message{
ID: "nextContext",
Other: "next context",
},
&i18n.Message{
ID: "attach",
Other: "attach",
},
&i18n.Message{
ID: "viewLogs",
Other: "view logs",
},
&i18n.Message{
ID: "ServicesTitle",
Other: "Services",
},
&i18n.Message{
ID: "ContainersTitle",
Other: "Containers",
},
&i18n.Message{
ID: "ImagesTitle",
Other: "Images",
},
&i18n.Message{
ID: "NoContainers",
Other: "No containers",
},
&i18n.Message{
ID: "NoImages",
Other: "No images",
},
&i18n.Message{
ID: "removeImage",
Other: "remove image",
},
&i18n.Message{
ID: "removeWithoutPrune",
Other: "remove without deleting untagged parents",
},
&i18n.Message{
ID: "mustForceToRemoveImage",
Other: "Regular image delete not allowed. Do you want to force remove this image?",
},
&i18n.Message{
ID: "pruneImages",
Other: "prune unused images",
},
&i18n.Message{
ID: "confirmPruneImages",
Other: "Are you sure you want to prune all unused images?",
},
&i18n.Message{
ID: "PruningStatus",
Other: "pruning",
},
&i18n.Message{
ID: "StopService",
Other: "Are you sure you want to stop this service's containers? (enter/esc)",
},
&i18n.Message{
ID: "pressEnterToReturn",
Other: "Press enter to return to lazydocker",
},
)
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",
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)",
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",
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)",
PressEnterToReturn: "Press enter to return to lazydocker",
}
}

@ -1,78 +1,40 @@
package i18n
import (
"strings"
"github.com/imdario/mergo"
"github.com/cloudfoundry/jibber_jabber"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/sirupsen/logrus"
"golang.org/x/text/language"
)
// 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 map[string]interface{}
// Localizer will translate a message into the user's language
type Localizer struct {
i18nLocalizer *i18n.Localizer
language string
Log *logrus.Entry
language string
Log *logrus.Entry
S TranslationSet
}
// NewLocalizer creates a new Localizer
func NewLocalizer(log *logrus.Entry) *Localizer {
// NewTranslationSet creates a new Localizer
func NewTranslationSet(log *logrus.Entry) TranslationSet {
userLang := detectLanguage(jibber_jabber.DetectLanguage)
log.Info("language: " + userLang)
return setupLocalizer(log, userLang)
}
// Localize handels the translations
// expects i18n.LocalizeConfig as input: https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n#Localizer.MustLocalize
// output: translated string
func (l *Localizer) Localize(config *i18n.LocalizeConfig) string {
return l.i18nLocalizer.MustLocalize(config)
}
set := englishSet()
// SLocalize (short localize) is for 1 line localizations
// ID: The id that is used in the .toml translation files
// Other: the default message it needs to return if there is no translation found or the system is english
func (l *Localizer) SLocalize(ID string) string {
return l.Localize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: ID,
},
})
}
userLang = "pl"
// TemplateLocalize allows the Other input to be dynamic
func (l *Localizer) TemplateLocalize(ID string, TemplateData map[string]interface{}) string {
return l.Localize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: ID,
},
TemplateData: TemplateData,
})
}
// GetLanguage returns the currently selected language, e.g 'en'
func (l *Localizer) GetLanguage() string {
return l.language
}
// add translation file(s)
func addBundles(log *logrus.Entry, i18nBundle *i18n.Bundle) {
fs := []func(*i18n.Bundle) error{
addPolish,
addDutch,
addEnglish,
if strings.HasPrefix(userLang, "pl") {
mergo.Merge(&set, polishSet(), mergo.WithOverride)
}
for _, f := range fs {
if err := f(i18nBundle); err != nil {
log.Fatal(err)
}
if strings.HasPrefix(userLang, "nl") {
mergo.Merge(&set, polishSet(), mergo.WithOverride)
}
return set
}
// detectLanguage extracts user language from environment
@ -83,20 +45,3 @@ func detectLanguage(langDetector func() (string, error)) string {
return "C"
}
// setupLocalizer creates a new localizer using given userLang
func setupLocalizer(log *logrus.Entry, userLang string) *Localizer {
// create a i18n bundle that can be used to add translations and other things
i18nBundle := &i18n.Bundle{DefaultLanguage: language.English}
addBundles(log, i18nBundle)
// return the new localizer that can be used to translate text
i18nLocalizer := i18n.NewLocalizer(i18nBundle, userLang)
return &Localizer{
i18nLocalizer: i18nLocalizer,
language: userLang,
Log: log,
}
}

@ -1,91 +0,0 @@
package i18n
import (
"fmt"
"io/ioutil"
"testing"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
func getDummyLog() *logrus.Entry {
log := logrus.New()
log.Out = ioutil.Discard
return log.WithField("test", "test")
}
// TestNewLocalizer is a function.
func TestNewLocalizer(t *testing.T) {
assert.NotNil(t, NewLocalizer(getDummyLog()))
}
// TestDetectLanguage is a function.
func TestDetectLanguage(t *testing.T) {
type scenario struct {
langDetector func() (string, error)
expected string
}
scenarios := []scenario{
{
func() (string, error) {
return "", fmt.Errorf("An error occurred")
},
"C",
},
{
func() (string, error) {
return "en", nil
},
"en",
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, detectLanguage(s.langDetector))
}
}
// TestLocalizer is a function.
func TestLocalizer(t *testing.T) {
type scenario struct {
userLang string
test func(*Localizer)
}
scenarios := []scenario{
{
"C",
func(l *Localizer) {
assert.EqualValues(t, "C", l.GetLanguage())
assert.Equal(t, "Diff", l.Localize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "DiffTitle",
},
}))
assert.Equal(t, "Diff", l.SLocalize("DiffTitle"))
assert.Equal(t, "Are you sure you want to delete the branch test?", l.TemplateLocalize("DeleteBranchMessage", Teml{"selectedBranchName": "test"}))
},
},
{
"nl",
func(l *Localizer) {
assert.EqualValues(t, "nl", l.GetLanguage())
assert.Equal(t, "Diff", l.Localize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "DiffTitle",
},
}))
assert.Equal(t, "Diff", l.SLocalize("DiffTitle"))
assert.Equal(t, "Weet je zeker dat je branch test wilt verwijderen?", l.TemplateLocalize("DeleteBranchMessage", Teml{"selectedBranchName": "test"}))
},
},
}
for _, s := range scenarios {
s.test(setupLocalizer(getDummyLog(), s.userLang))
}
}

@ -1,15 +1,5 @@
package i18n
import (
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
func addPolish(i18nObject *i18n.Bundle) error {
return i18nObject.AddMessages(language.Polish,
&i18n.Message{
ID: "NotEnoughSpace",
Other: "Za mało miejsca do wyświetlenia paneli",
})
func polishSet() TranslationSet {
return TranslationSet{}
}

Loading…
Cancel
Save