Skip to content

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

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

Merged
merged 1 commit into from
Jul 28, 2021
Merged

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

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()
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jul 23, 2021
@per1234 per1234 requested review from silvanocerza and umbynos July 23, 2021 23:22
@per1234 per1234 merged commit 7b68b48 into arduino:master Jul 28, 2021
@per1234 per1234 deleted the i18n-import-cycle branch July 28, 2021 16:03
@per1234 per1234 self-assigned this Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants