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

Fix empty string shown if company name is empty #804

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

gersonnoboa
Copy link
Contributor

@gersonnoboa gersonnoboa commented Oct 19, 2023

If the company name is empty in the custom locales set in the web (as is the default), then the widgets tried to get it, but as it is empty, then the fallback was the theme and the configuration. If neither of those was able to provide a non-empty value, then the idea is to use the local fallback. However, for this I was mistakenly using the value from Localizable.tr. The problem is that this method first attempts to get it again from the string provider. As we determined in the first step, this is empty. However, Localizable.tr doesn't filter empty values, as all other strings can legitimately be empty. So the method returns empty string, and this is shown on the widgets.

The solution was to create a new value in the SwiftGen stencil, which is called companyNameLocalFallbackOnly. As the name says, this variable sends the string provider as nil, thus ignoring the company name's empty value, and using the value in the Localizable.strings, or the hardcoded "Company Name" as fallback.

For now, no other string is subject to this matter where the string can come from a lot of various sources, so this approach should be sufficient. If at some point it happens that quite a lot of strings need to be fetched from various sources, what can be done is that the stencil can be changed so that instead of generating static lets, we generate static funcs, and then we can easily send the string provider as needed.

MOB-2768

Release notes:

  • Feature
  • Ignore
  • Release notes (Is it clear from the description here?)
  • Migration guide (If changes are needed for integrator already using the SDK - what needs to be communicated? Add underneath please)

Additional info:

  • Tests fixed, added? Unit, acceptance, snapshots?
  • Logging necessary for future troubleshooting of customer issues added?

Screenshots:

If the company name is empty in the custom locales set in the web (as is the
default), then the widgets tried to get it, but as it is empty, then the
fallback was the theme and the configuration. If neither of those was able to
provide a non-empty value, then the idea is to use the local fallback. However,
for this I was mistakenly using the value from `Localizable.tr`. The problem is
that this method first attempts to get it again from the string provider. As we
determined in the first step, this is empty. However, `Localizable.tr` doesn't
filter empty values, as all other strings can legitimately be empty. So the
method returns empty string, and this is shown on the widgets.

The solution was to create a new value in the SwiftGen stencil, which is called
`companyNameLocalFallbackOnly`. As the name says, this variable sends the string
provider as nil, thus ignoring the company name's empty value, and using the
value in the `Localizable.strings`, or the hardcoded "Company Name" as fallback.

For now, no other string is subject to this matter where the string can come
from a lot of various sources, so this approach should be sufficient. If at some
point it happens that quite a lot of strings need to be fetched from various
sources, what can be done is that the stencil can be changed so that instead of
generating `static let`s, we generate `static func`s, and then we can easily
send the string provider as needed.

MOB-2768
@gersonnoboa gersonnoboa merged commit 8a2f708 into development Oct 19, 2023
1 check passed
@gersonnoboa gersonnoboa deleted the MOB-2768 branch October 19, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants