Skip to content
Snippets Groups Projects
Unverified Commit b0147303 authored by Walter Leibbrandt's avatar Walter Leibbrandt Committed by GitHub
Browse files

Wrap `tru` and `trs` macro results in `str` (#10571)

* Add versions of `trs` and `tru` that wrap results in `str`

The pre-existing `trs` and `tru` were renamed to `lazy-trs` and `lazy-tru`
respectively, and new `trs` and `tru` funcs were added, wrapping the result
of its lazy counterpart in `str`.

This way the normal use case of `trs` and `tru` is improved by no longer
requiring that it be wrapped in `str`.

Cases where the translated result is passed to `str` anyway, the lazy
version can be used.

* `(str (trs ...))` → `(trs ...)`

And the same for `tru`.

* Allow `defsetting` descriptions to use lazy versions of `trs`/`tru`

* Use `lazy-trs`/`lazy-tru` where `str` is applied separately

* Remove unnecessary `vec` from `tru`/`trs` macros

* puppetlabs.i18n does not have a `lazy-tru`

* Missed some settings that now need to use `lazy-tru`

* Only use `lazy-tru` in top-level `def`s

If the localized strings are looked up on module import, before locales are
loaded, the lookup will fail and the original input string will be used.

* Fix bad usages of `tru` that should be `lazy-tru`

* s/lazy-tr/deferred-tr/g

* Avoid `tr*` macros being used in top-level (compile time) statements

Because localizations are not yet loaded at compile time.

* Add type hint for `str*` wrapping of `trs`/`tru`

* Fix assigned function's return type hint

* Expand docstrings for `i18n/tr[su]`

* Use `trs` and `tru` from metabase.util.i18n instead of puppetlabs.i18n.core

* Defer compile time translation lookups

These changes were pointed out by exceptions generated by `i18n/str*`.

* Remove unused `require`d function

* New compile time `trs` usages caught by `lein uberjar`

* Ensure that error message from db driver is a string

It is necessary to ensure that the error message is a string, because some
db driver errors come from statically declared error messages, using
`deferred-tru`. Like those in
`metabase.driver.common/connection-error-messages`.

Fixes #10347 and #10473.

* Remove string type hint from `humanize-connect-error-message`
parent 9a264146
No related branches found
No related tags found
No related merge requests found
Showing
with 122 additions and 121 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment