Skip to content

Commit

Permalink
more i18n messages add
Browse files Browse the repository at this point in the history
  • Loading branch information
coby2023t committed Sep 13, 2023
1 parent 3746c58 commit eff6626
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion arduino/builder/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ type includeCacheEntry struct {

// String fixdoc
func (entry *includeCacheEntry) String() string {
return fmt.Sprintf("SourceFile: %s; Include: %s; IncludePath: %s",
return fmt.Sprintf(tr("SourceFile: %s; Include: %s; IncludePath: %s"),
entry.Sourcefile, entry.Include, entry.Includepath)
}

Expand Down
20 changes: 10 additions & 10 deletions arduino/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type discoveryMessage struct {
}

func (msg discoveryMessage) String() string {
s := fmt.Sprintf("type: %s", msg.EventType)
s := fmt.Sprintf(tr("type: %s"), msg.EventType)
if msg.Message != "" {
s = tr("%[1]s, message: %[2]s", s, msg.Message)
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
disc.incomingMessagesError = err
disc.statusMutex.Unlock()
close(outChan)
logrus.Errorf("stopped discovery %s decode loop: %v", disc.id, err)
logrus.Errorf(tr("stopped discovery %s decode loop: %v"), disc.id, err)
}

for {
Expand All @@ -206,7 +206,7 @@ func (disc *PluggableDiscovery) jsonDecodeLoop(in io.Reader, outChan chan<- *dis
closeAndReportError(err)
return
}
logrus.Infof("from discovery %s received message %s", disc.id, msg)
logrus.Infof(tr("from discovery %s received message %s"), disc.id, msg)
if msg.EventType == "add" {
if msg.Port == nil {
closeAndReportError(errors.New(tr("invalid 'add' message: missing port")))
Expand Down Expand Up @@ -253,7 +253,7 @@ func (disc *PluggableDiscovery) waitMessage(timeout time.Duration) (*discoveryMe
}

func (disc *PluggableDiscovery) sendCommand(command string) error {
logrus.Infof("sending command %s to discovery %s", strings.TrimSpace(command), disc)
logrus.Infof(tr("sending command %s to discovery %s"), strings.TrimSpace(command), disc)
data := []byte(command)
for {
n, err := disc.outgoingCommandsPipe.Write(data)
Expand All @@ -268,7 +268,7 @@ func (disc *PluggableDiscovery) sendCommand(command string) error {
}

func (disc *PluggableDiscovery) runProcess() error {
logrus.Infof("starting discovery %s process", disc.id)
logrus.Infof(tr("starting discovery %s process"), disc.id)
proc, err := executils.NewProcess(nil, disc.processArgs...)
if err != nil {
return err
Expand All @@ -295,12 +295,12 @@ func (disc *PluggableDiscovery) runProcess() error {
defer disc.statusMutex.Unlock()
disc.process = proc
disc.state = Alive
logrus.Infof("started discovery %s process", disc.id)
logrus.Infof(tr("started discovery %s process"), disc.id)
return nil
}

func (disc *PluggableDiscovery) killProcess() error {
logrus.Infof("killing discovery %s process", disc.id)
logrus.Infof(tr("killing discovery %s process"), disc.id)
if disc.process != nil {
if err := disc.process.Kill(); err != nil {
return err
Expand All @@ -313,7 +313,7 @@ func (disc *PluggableDiscovery) killProcess() error {
defer disc.statusMutex.Unlock()
disc.stopSync()
disc.state = Dead
logrus.Infof("killed discovery %s process", disc.id)
logrus.Infof(tr("killed discovery %s process"), disc.id)
return nil
}

Expand All @@ -335,7 +335,7 @@ func (disc *PluggableDiscovery) Run() (err error) {
if err := disc.killProcess(); err != nil {
// Log failure to kill the process, ideally that should never happen
// but it's best to know it if it does
logrus.Errorf("Killing discovery %s after unsuccessful start: %s", disc.id, err)
logrus.Errorf(tr("Killing discovery %s after unsuccessful start: %s"), disc.id, err)
}
}()

Expand Down Expand Up @@ -415,7 +415,7 @@ func (disc *PluggableDiscovery) stopSync() {
func (disc *PluggableDiscovery) Quit() {
_ = disc.sendCommand("QUIT\n")
if _, err := disc.waitMessage(time.Second * 5); err != nil {
logrus.Errorf("Quitting discovery %s: %s", disc.id, err)
logrus.Errorf(tr("Quitting discovery %s: %s"), disc.id, err)
}
disc.stopSync()
disc.killProcess()
Expand Down
14 changes: 7 additions & 7 deletions arduino/libraries/librariesresolver/cpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,20 @@ func (resolver *Cpp) AlternativesFor(header string) libraries.List {
// ResolveFor finds the most suitable library for the specified combination of
// header and architecture. If no libraries provides the requested header, nil is returned
func (resolver *Cpp) ResolveFor(header, architecture string) *libraries.Library {
logrus.Infof("Resolving include %s for arch %s", header, architecture)
logrus.Infof(tr("Resolving include %s for arch %s"), header, architecture)
var found libraries.List
var foundPriority int
for _, lib := range resolver.headers[header] {
libPriority := ComputePriority(lib, header, architecture)
msg := " discarded"
msg := tr(" discarded")
if found == nil || foundPriority < libPriority {
found = libraries.List{}
found.Add(lib)
foundPriority = libPriority
msg = " found better lib"
msg = tr(" found better lib")
} else if foundPriority == libPriority {
found.Add(lib)
msg = " found another lib with same priority"
msg = tr(" found another lib with same priority")
}
logrus.
WithField("lib", lib.Name).
Expand All @@ -149,12 +149,12 @@ func (resolver *Cpp) ResolveFor(header, architecture string) *libraries.Library
// If more than one library qualifies use the "closestmatch" algorithm to
// find the best matching one (instead of choosing it randomly)
if best := findLibraryWithNameBestDistance(header, found); best != nil {
logrus.WithField("lib", best.Name).Info(" library with the best matching name")
logrus.WithField("lib", best.Name).Info(tr(" library with the best matching name"))
return best
}

found.SortByName()
logrus.WithField("lib", found[0].Name).Info(" first library in alphabetic order")
logrus.WithField("lib", found[0].Name).Info(tr(" first library in alphabetic order"))
return found[0]
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func ComputePriority(lib *libraries.Library, header, arch string) int {
// Bonus for libraries specified via --libraries flags, those libraries gets the highest priority
priority += 10000
default:
panic(fmt.Sprintf("Invalid library location: %d", lib.Location))
panic(fmt.Sprintf(tr("Invalid library location: %d"), lib.Location))
}
return priority
}
Expand Down
12 changes: 6 additions & 6 deletions arduino/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ type PortParameterDescriptor struct {
}

func (msg monitorMessage) String() string {
s := fmt.Sprintf("type: %s", msg.EventType)
s := fmt.Sprintf(tr("type: %s"), msg.EventType)
if msg.Message != "" {
s = fmt.Sprintf("%[1]s, message: %[2]s", s, msg.Message)
s = fmt.Sprintf(tr("%[1]s, message: %[2]s"), s, msg.Message)
}
if msg.ProtocolVersion != 0 {
s = fmt.Sprintf("%[1]s, protocol version: %[2]d", s, msg.ProtocolVersion)
s = fmt.Sprintf(tr("%[1]s, protocol version: %[2]d"), s, msg.ProtocolVersion)
}
if msg.PortDescription != nil {
s = fmt.Sprintf("%s, port descriptor: protocol %s, %d parameters",
s = fmt.Sprintf(tr("%s, port descriptor: protocol %s, %d parameters"),
s, msg.PortDescription.Protocol, len(msg.PortDescription.ConfigurationParameters))
}
return s
Expand Down Expand Up @@ -253,7 +253,7 @@ func (mon *PluggableMonitor) Describe() (*PortDescriptor, error) {

// Configure sets a port configuration parameter.
func (mon *PluggableMonitor) Configure(param, value string) error {
if err := mon.sendCommand(fmt.Sprintf("CONFIGURE %s %s\n", param, value)); err != nil {
if err := mon.sendCommand(fmt.Sprintf(tr("CONFIGURE %s %s\n"), param, value)); err != nil {
return err
}
_, err := mon.waitMessage(time.Second*10, "configure")
Expand All @@ -273,7 +273,7 @@ func (mon *PluggableMonitor) Open(portAddress, portProtocol string) (io.ReadWrit
defer tcpListener.Close()
tcpListenerPort := tcpListener.Addr().(*net.TCPAddr).Port

if err := mon.sendCommand(fmt.Sprintf("OPEN 127.0.0.1:%d %s\n", tcpListenerPort, portAddress)); err != nil {
if err := mon.sendCommand(fmt.Sprintf(tr("OPEN 127.0.0.1:%d %s\n"), tcpListenerPort, portAddress)); err != nil {
return nil, err
}
if _, err := mon.waitMessage(time.Second*10, "open"); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions i18n/cmd/commands/transifex/pull_transifex.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func getDownloadURL(languageCode, downloadID string) string {
case "pending":
fallthrough
case "processing":
fmt.Printf("Current status for language %s: %s\n", languageCode, status)
fmt.Printf(tr("Current status for language %s: %s\n"), languageCode, status)

Check failure on line 226 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 226 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 226 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 226 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr
time.Sleep(backoff)
backoff = backoff * 2
// Request the status again
Expand All @@ -234,14 +234,14 @@ func getDownloadURL(languageCode, downloadID string) string {
}
os.Exit(1)
}
fmt.Printf("Status request for language %s failed in an unforeseen way\n", languageCode)
fmt.Printf(tr("Status request for language %s failed in an unforeseen way\n"), languageCode)

Check failure on line 237 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 237 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 237 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 237 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr
os.Exit(1)
}
}

// download file from url and saves it in folder with the specified fileName
func download(folder, fileName, url string) {
fmt.Printf("Starting download of %s\n", fileName)
fmt.Printf(tr("Starting download of %s\n"), fileName)

Check failure on line 244 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 244 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 244 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 244 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr
filePath := paths.New(folder, fileName)

res, err := http.DefaultClient.Get(url)
Expand All @@ -257,12 +257,12 @@ func download(folder, fileName, url string) {
}

filePath.WriteFile(data)
fmt.Printf("Finished download of %s\n", fileName)
fmt.Printf(tr("Finished download of %s\n"), fileName)

Check failure on line 260 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 260 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 260 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 260 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr
}

func pullCatalog(cmd *cobra.Command, args []string) {
languages := getLanguages()
fmt.Println("translations found:", languages)
fmt.Println(tr("translations found:"), languages)

Check failure on line 265 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 265 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 265 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 265 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr

folder := args[0]

Expand All @@ -277,5 +277,5 @@ func pullCatalog(cmd *cobra.Command, args []string) {
}(lang)
}
wg.Wait()
fmt.Println("Translation files downloaded")
fmt.Println(tr("Translation files downloaded"))

Check failure on line 280 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: tr

Check failure on line 280 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: tr

Check failure on line 280 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: tr

Check failure on line 280 in i18n/cmd/commands/transifex/pull_transifex.go

View workflow job for this annotation

GitHub Actions / check-errors (./)

undefined: tr
}
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func createCliCommandTree(cmd *cobra.Command) {
})
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", tr("The custom config file (if not specified the default will be used)."))
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, tr("Comma-separated list of additional URLs for the Boards Manager."))
cmd.PersistentFlags().Bool("no-color", false, "Disable colored output.")
cmd.PersistentFlags().Bool("no-color", false, tr("Disable colored output."))
configuration.BindFlags(cmd, configuration.Settings)
}

Expand Down
4 changes: 2 additions & 2 deletions legacy/builder/recipe_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func RecipeByPrefixSuffixRunner(
buildProps *properties.Map,
builderLogger *logger.BuilderLogger,
) error {
logrus.Debugf(fmt.Sprintf("Looking for recipes like %s", prefix+"*"+suffix))
logrus.Debugf(fmt.Sprintf(tr("Looking for recipes like %s"), prefix+"*"+suffix))

// TODO is it necessary to use Clone?
buildProperties := buildProps.Clone()
Expand All @@ -42,7 +42,7 @@ func RecipeByPrefixSuffixRunner(
// TODO is it necessary to use Clone?
properties := buildProperties.Clone()
for _, recipe := range recipes {
logrus.Debugf(fmt.Sprintf("Running recipe: %s", recipe))
logrus.Debugf(fmt.Sprintf(tr("Running recipe: %s"), recipe))

command, err := utils.PrepareCommandForRecipe(properties, recipe, false)
if err != nil {
Expand Down

0 comments on commit eff6626

Please sign in to comment.