mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
Translate progress bar
This commit is contained in:
parent
a41318d822
commit
1f3247c3ff
5 changed files with 251 additions and 10 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
"github.com/fatih/color"
|
||||
"github.com/vbauerster/mpb/v8"
|
||||
"github.com/vbauerster/mpb/v8/decor"
|
||||
"go.uploadedlobster.com/scotty/internal/i18n"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
|
@ -35,8 +36,8 @@ func progressBar(wg *sync.WaitGroup, exportProgress chan models.Progress, import
|
|||
mpb.WithAutoRefresh(),
|
||||
)
|
||||
|
||||
exportBar := setupProgressBar(p, "exporting")
|
||||
importBar := setupProgressBar(p, "importing")
|
||||
exportBar := setupProgressBar(p, i18n.Tr("exporting"))
|
||||
importBar := setupProgressBar(p, i18n.Tr("importing"))
|
||||
go updateProgressBar(exportBar, wg, exportProgress)
|
||||
go updateProgressBar(importBar, wg, importProgress)
|
||||
|
||||
|
@ -58,7 +59,7 @@ func setupProgressBar(p *mpb.Progress, name string) *mpb.Bar {
|
|||
mpb.AppendDecorators(
|
||||
decor.OnComplete(
|
||||
decor.EwmaETA(decor.ET_STYLE_GO, 0, decor.WC{C: decor.DSyncWidth}),
|
||||
"done",
|
||||
i18n.Tr("done"),
|
||||
),
|
||||
// decor.OnComplete(decor.Percentage(decor.WC{W: 5, C: decor.DSyncWidthR}), "done"),
|
||||
decor.Name(" "),
|
||||
|
|
|
@ -46,12 +46,16 @@ var messageKeyToIndex = map[string]int{
|
|||
"Imported %v of %v %s into %v.": 3,
|
||||
"Latest timestamp: %v (%v)\n": 6,
|
||||
"Transferring %s from %s to %s...": 0,
|
||||
"done": 9,
|
||||
"exporting": 7,
|
||||
"importing": 8,
|
||||
}
|
||||
|
||||
var deIndex = []uint32{ // 8 elements
|
||||
var deIndex = []uint32{ // 11 elements
|
||||
0x00000000, 0x00000029, 0x00000047, 0x00000087,
|
||||
0x000000b2, 0x000000e9, 0x000000fc, 0x00000125,
|
||||
} // Size: 56 bytes
|
||||
0x00000125, 0x00000125, 0x00000125,
|
||||
} // Size: 68 bytes
|
||||
|
||||
const deData string = "" + // Size: 293 bytes
|
||||
"\x02Übertrage %[1]s von %[2]s nach %[3]s...\x02Ab Zeitstempel: %[1]v (%[" +
|
||||
|
@ -60,16 +64,17 @@ const deData string = "" + // Size: 293 bytes
|
|||
"nd folgende Fehler aufgetreten:\x04\x00\x01\x0a\x0e\x02Fehler: %[1]v\x04" +
|
||||
"\x00\x01\x0a$\x02Neuester Zeitstempel: %[1]v (%[2]v)"
|
||||
|
||||
var enIndex = []uint32{ // 8 elements
|
||||
var enIndex = []uint32{ // 11 elements
|
||||
0x00000000, 0x0000002a, 0x00000048, 0x00000081,
|
||||
0x000000ab, 0x000000dc, 0x000000ee, 0x00000113,
|
||||
} // Size: 56 bytes
|
||||
0x0000011d, 0x00000127, 0x0000012c,
|
||||
} // Size: 68 bytes
|
||||
|
||||
const enData string = "" + // Size: 275 bytes
|
||||
const enData string = "" + // Size: 300 bytes
|
||||
"\x02Transferring %[1]s from %[2]s to %[3]s...\x02From timestamp: %[1]v (" +
|
||||
"%[2]v)\x02Import failed, last reported timestamp was %[1]v (%[2]v)\x02Im" +
|
||||
"ported %[1]v of %[2]v %[3]s into %[4]v.\x02During the import the followi" +
|
||||
"ng errors occurred:\x04\x00\x01\x0a\x0d\x02Error: %[1]v\x04\x00\x01\x0a " +
|
||||
"\x02Latest timestamp: %[1]v (%[2]v)"
|
||||
"\x02Latest timestamp: %[1]v (%[2]v)\x02exporting\x02importing\x02done"
|
||||
|
||||
// Total table size 680 bytes (0KiB); checksum: D0CBF9F5
|
||||
// Total table size 729 bytes (0KiB); checksum: A7E71D11
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
{
|
||||
"language": "de",
|
||||
"messages": [
|
||||
{
|
||||
"id": "exporting",
|
||||
"message": "exporting",
|
||||
"translation": ""
|
||||
},
|
||||
{
|
||||
"id": "importing",
|
||||
"message": "importing",
|
||||
"translation": ""
|
||||
},
|
||||
{
|
||||
"id": "done",
|
||||
"message": "done",
|
||||
"translation": ""
|
||||
},
|
||||
{
|
||||
"id": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
"message": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
|
|
199
internal/translations/locales/en/messages.gotext.json
Normal file
199
internal/translations/locales/en/messages.gotext.json
Normal file
|
@ -0,0 +1,199 @@
|
|||
{
|
||||
"language": "en",
|
||||
"messages": [
|
||||
{
|
||||
"id": "exporting",
|
||||
"message": "exporting",
|
||||
"translation": "exporting",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "importing",
|
||||
"message": "importing",
|
||||
"translation": "importing",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "done",
|
||||
"message": "done",
|
||||
"translation": "done",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
"message": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
"translation": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "Entity",
|
||||
"string": "%[1]s",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 1,
|
||||
"expr": "c.entity"
|
||||
},
|
||||
{
|
||||
"id": "SourceName",
|
||||
"string": "%[2]s",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 2,
|
||||
"expr": "c.sourceName"
|
||||
},
|
||||
{
|
||||
"id": "TargetName",
|
||||
"string": "%[3]s",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 3,
|
||||
"expr": "c.targetName"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "From timestamp: {Timestamp} ({Unix})",
|
||||
"message": "From timestamp: {Timestamp} ({Unix})",
|
||||
"translation": "From timestamp: {Timestamp} ({Unix})",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "Timestamp",
|
||||
"string": "%[1]v",
|
||||
"type": "time.Time",
|
||||
"underlyingType": "struct{wall uint64; ext int64; loc *time.Location}",
|
||||
"argNum": 1,
|
||||
"expr": "timestamp"
|
||||
},
|
||||
{
|
||||
"id": "Unix",
|
||||
"string": "%[2]v",
|
||||
"type": "int64",
|
||||
"underlyingType": "int64",
|
||||
"argNum": 2,
|
||||
"expr": "timestamp.Unix()"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Import failed, last reported timestamp was {LastTimestamp} ({Unix})",
|
||||
"message": "Import failed, last reported timestamp was {LastTimestamp} ({Unix})",
|
||||
"translation": "Import failed, last reported timestamp was {LastTimestamp} ({Unix})",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "LastTimestamp",
|
||||
"string": "%[1]v",
|
||||
"type": "time.Time",
|
||||
"underlyingType": "struct{wall uint64; ext int64; loc *time.Location}",
|
||||
"argNum": 1,
|
||||
"expr": "result.LastTimestamp"
|
||||
},
|
||||
{
|
||||
"id": "Unix",
|
||||
"string": "%[2]v",
|
||||
"type": "int64",
|
||||
"underlyingType": "int64",
|
||||
"argNum": 2,
|
||||
"expr": "result.LastTimestamp.Unix()"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Imported {ImportCount} of {TotalCount} {Entity} into {TargetName}.",
|
||||
"message": "Imported {ImportCount} of {TotalCount} {Entity} into {TargetName}.",
|
||||
"translation": "Imported {ImportCount} of {TotalCount} {Entity} into {TargetName}.",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "ImportCount",
|
||||
"string": "%[1]v",
|
||||
"type": "int",
|
||||
"underlyingType": "int",
|
||||
"argNum": 1,
|
||||
"expr": "result.ImportCount"
|
||||
},
|
||||
{
|
||||
"id": "TotalCount",
|
||||
"string": "%[2]v",
|
||||
"type": "int",
|
||||
"underlyingType": "int",
|
||||
"argNum": 2,
|
||||
"expr": "result.TotalCount"
|
||||
},
|
||||
{
|
||||
"id": "Entity",
|
||||
"string": "%[3]s",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 3,
|
||||
"expr": "c.entity"
|
||||
},
|
||||
{
|
||||
"id": "TargetName",
|
||||
"string": "%[4]v",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 4,
|
||||
"expr": "c.targetName"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "During the import the following errors occurred:",
|
||||
"message": "During the import the following errors occurred:",
|
||||
"translation": "During the import the following errors occurred:",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Error: {Err}",
|
||||
"message": "Error: {Err}",
|
||||
"translation": "Error: {Err}",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "Err",
|
||||
"string": "%[1]v",
|
||||
"type": "string",
|
||||
"underlyingType": "string",
|
||||
"argNum": 1,
|
||||
"expr": "err"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Latest timestamp: {LastTimestamp} ({Unix})",
|
||||
"message": "Latest timestamp: {LastTimestamp} ({Unix})",
|
||||
"translation": "Latest timestamp: {LastTimestamp} ({Unix})",
|
||||
"translatorComment": "Copied from source.",
|
||||
"placeholders": [
|
||||
{
|
||||
"id": "LastTimestamp",
|
||||
"string": "%[1]v",
|
||||
"type": "time.Time",
|
||||
"underlyingType": "struct{wall uint64; ext int64; loc *time.Location}",
|
||||
"argNum": 1,
|
||||
"expr": "result.LastTimestamp"
|
||||
},
|
||||
{
|
||||
"id": "Unix",
|
||||
"string": "%[2]v",
|
||||
"type": "int64",
|
||||
"underlyingType": "int64",
|
||||
"argNum": 2,
|
||||
"expr": "result.LastTimestamp.Unix()"
|
||||
}
|
||||
],
|
||||
"fuzzy": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,27 @@
|
|||
{
|
||||
"language": "en",
|
||||
"messages": [
|
||||
{
|
||||
"id": "exporting",
|
||||
"message": "exporting",
|
||||
"translation": "exporting",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "importing",
|
||||
"message": "importing",
|
||||
"translation": "importing",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "done",
|
||||
"message": "done",
|
||||
"translation": "done",
|
||||
"translatorComment": "Copied from source.",
|
||||
"fuzzy": true
|
||||
},
|
||||
{
|
||||
"id": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
"message": "Transferring {Entity} from {SourceName} to {TargetName}...",
|
||||
|
|
Loading…
Add table
Reference in a new issue