Fix empty string shown if company name is empty #804
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theLocalizable.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 generatestatic func
s, and then we can easily send the string provider as needed.MOB-2768
Release notes:
Additional info:
Screenshots: