-
-
Notifications
You must be signed in to change notification settings - Fork 304
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: productName best localized choice #4746
fix: productName best localized choice #4746
Conversation
Impacted files: * `nutrition_page_loaded.dart`: minor refactoring * `product_cards_helper.dart`: now the product name is taken from the localized version first; minor refactoring
Codecov Report
@@ Coverage Diff @@
## develop #4746 +/- ##
==========================================
- Coverage 9.89% 9.89% -0.01%
==========================================
Files 312 312
Lines 15809 15810 +1
==========================================
Hits 1565 1565
- Misses 14244 14245 +1
📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
There hasn't been a change on the server side. product_name contains the name of the product in its main language (indicated by the lc field of the product), it does not changed based on the lc field of the request. |
Strange, because there was no change on our code either and suddenly tests started to fail.
Aha, we were not aware of the existence of the
@stephanegigandet Could you please confirm that, so that I can add field
Then our tests were wrong from the very start. But still passed for some reason. That said, your comment confirms that the current PR will be an improvement in Smoothie: instead of displaying always the "main" product_name (that always relates to the main product language called |
@teolemon review ping |
@monsieurtanuki When you read products, the "lc" field and the "lang" field you get back in the JSON have the same value: the main language of the product. When you write products, you have to use "lang" to specify the main language of the product, and "lc" is the language you are sending fields for (e.g. lc : fr, lang : de, product_name : nom en français) |
@stephanegigandet Thank you for this clarification. |
@teolemon Now that the possible confusion between |
@teolemon Still not interested in using the best product name? |
product.productName ?? | ||
product.productNameInLanguages?[ProductQuery.getLanguage()] ?? | ||
/// Returns a trimmed version of the string, or null if null or empty. | ||
String? _clearString(final String? string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of feature may be useful elsewhere in the app.
I suggests to move-it to a helper-like class, or even better as an extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factorization would indeed be nice @monsieurtanuki , but approving anyway
Thank you guys for your comments and reviews! |
What
productName
to match the specified language, even if a localization is available. Looks like the product name is computed when the data is input (as product name or as localized product names), and then regardless of the language of the "get" queries later we always get the same product name.Screenshot
The product name changes between the 2 screenshots (it was not the case before this PR):
Impacted files
nutrition_page_loaded.dart
: minor refactoringproduct_cards_helper.dart
: now the product name is taken from the localized version first; minor refactoring