The Wayback Machine - https://web.archive.org/web/20210911024510/https://github.com/arduino/arduino-cli/pull/1365
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

[breaking] Pass user locale preference directly to i18n package #1365

Merged
merged 1 commit into from Jul 28, 2021

Conversation

@per1234
Copy link
Contributor

@per1234 per1234 commented Jul 23, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Code restructuring

  • What is the current behavior?

The user can configure their locale preference via the undocumented locale configuration key. This information is given priority by the github.com/arduino/arduino-cli/configuration package over the automatically detected locale.

Previously, the i18n package got the configuration setting from the github.com/arduino/arduino-cli/configuration package, but this will result in an import cycle when the i18n package is used to enable translation of the output strings of the
configuration package.

  • What is the new behavior?

To avoid this import cycle, the caller now reads the configuration and passes the locale code to the i18n package via the Init
function:

i18n.Init("it")

The argument may be omitted if only automated locale detection is needed:

i18n.Init()

Does this PR introduce a breaking change

yes

is titled accordingly

yes

The user can configure their locale preference via the `locale` configuration key. This information is given priority by
the `github.com/arduino/arduino-cli/configuration` package over the automatically detected locale.

Previously, the `i18n` package got the configuration setting from the `github.com/arduino/arduino-cli/configuration`
package, but this will result in an import cycle when the `i18n` package is used to enable translation of the output
strings of the `configuration` package.

To avoid this, the caller now reads the configuration and passes the locale code to the `i18n` package via its `Init`
function:

i18n.Init("it")

The argument can be omitted if only automated locale detection is needed:

i18n.Init()
i18n/i18n.go Show resolved Hide resolved
i18n/i18n.go Show resolved Hide resolved
@per1234 per1234 merged commit 7b68b48 into arduino:master Jul 28, 2021
8 checks passed
8 checks passed
@github-actions
verify-links
Details
@github-actions
verify-formatting
Details
@github-actions
test-matrix (ubuntu-20.04)
Details
@github-actions
validate
Details
@github-actions
test-matrix (windows-latest)
Details
@github-actions
test-matrix (macOS-latest)
Details
@github-actions
create-test-artifacts
Details
license/cla Contributor License Agreement is signed.
Details
@per1234 per1234 deleted the per1234:i18n-import-cycle branch Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants