Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new language po file for zh_TW kk_KZ lb_LU #2301

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the initial internationalization effort, we decided that the log messages would be excluded from the internationalization scope for now. The reason is that the addition of these strings would significantly increase the workload on the community translators, while generally being of less visibility and/or importance to the users.

Even though on an individual basis there are surely specific log messages of higher importance than specific non-log strings that were internationalized, the log/non-log dichotomy provided an objective criterion for determining which strings were in scope for the initial effort.

We considered eventually expanding the i18n coverage at some time in the future after there has been good progress on the initial translation effort. However, from looking at the translation coverage on the Transifex project home page:

https://explore.transifex.com/arduino-1/arduino-cli/

it seems to me that the translation coverage is not very good overall so I don't think it is a good idea to increase the translator workload by internationalization of log messages unless there are specific cases where a message is highly visible to a significant number of users for some reason.

}

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logrus.Infof(tr("from discovery %s received message %s"), disc.id, msg)
logrus.Infof(tr("from discovery %[1]s received message %[2]s"), disc.id, msg)

As mentioned above, I am opposed to the arbitrary internationalization of log messages. However, since you are interested in assisting in the internationalization effort I will add a note about how we handle this type of string:

Indices should be added to printf verbs when multiple are present in a string.

This allows the translator to easily insert them at the appropriate location in the sentence structure without being required to understand the Go printf syntax and without being restricted to their relative order in the English language source string.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err := mon.sendCommand(fmt.Sprintf(tr("CONFIGURE %s %s\n"), param, value)); err != nil {
if err := mon.sendCommand(fmt.Sprintf("CONFIGURE %s %s\n", param, value)); err != nil {

This is code, not prose, so it must not be localized:

https://arduino.github.io/arduino-cli/dev/pluggable-monitor-specification/#configure-command

The CONFIGURE command is still CONFIGURE in any locale.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err := mon.sendCommand(fmt.Sprintf(tr("OPEN 127.0.0.1:%d %s\n"), tcpListenerPort, portAddress)); err != nil {
if err := mon.sendCommand(fmt.Sprintf("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
15 changes: 9 additions & 6 deletions i18n/cmd/commands/transifex/pull_transifex.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ import (

"github.com/arduino/go-paths-helper"
"github.com/spf13/cobra"
"github.com/arduino/arduino-cli/i18n"
)

var tr = i18n.Tr

var pullTransifexCommand = &cobra.Command{
Use: "pull [catalog folder]",
Short: "pulls the translation files from transifex",
Expand Down Expand Up @@ -223,7 +226,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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to internationalize this internal utility package. Doing so would increase the workload for the community translators without any significant benefit for the project users in return.

Credentials in the Transifex project are required to run this, which only a few select administrators would have. This is intended to be ran automatically by the continuous distribution system, so the logs are only ever viewed in the case of the need to troubleshoot a failure. In that rare eventuality, if the person doing the troubleshooting didn't have English language fluency, they could use an automatic translation service (e.g., Google Translate) on the messages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, these messages will never reach any arduino-cli user.

time.Sleep(backoff)
backoff = backoff * 2
// Request the status again
Expand All @@ -234,14 +237,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)
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)
filePath := paths.New(folder, fileName)

res, err := http.DefaultClient.Get(url)
Expand All @@ -257,12 +260,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)
}

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

folder := args[0]

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