-
-
Notifications
You must be signed in to change notification settings - Fork 75
docs: Update DOCUMENTATION.md #1111
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
base: master
Are you sure you want to change the base?
Conversation
| language: OpenFoodFactsLanguage.GERMAN, | ||
| fields: [ProductField.NAME] | ||
| ); | ||
| final product = await OpenFoodAPIClient.getProductV3(conf); |
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.
to check
| // The requested language is German, so `product.productName` | ||
| // either is in German, or in main product's language, or null. | ||
| var name = product.productName ?? 'No name'; | ||
| var name = product.product?.productName ?? 'No name'; |
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.
to check
| // Erase not translated categories (e.g. "en:cake"). | ||
| categories = categories.where((c) => !c.startsWith(RegExp('\w+:'))); | ||
| // Erase not translated categories (e.g., "en:cake"). | ||
| categories = categories?.where((c) => !c.startsWith(RegExp(r'\w+:'))).toList(); |
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.
to check
| #### Updating German Product Categories | ||
|
|
||
| ```dart | ||
| final conf = ProductQueryConfiguration( |
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.
to check
| // The requested language is German, so `product.productName` | ||
| // either is in German, or in main product's language, or null. | ||
| var name = product.productName ?? 'No name'; | ||
| var name = product.product?.productName ?? 'No name'; |
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.
| var name = product.product?.productName ?? 'No name'; | |
| var name = product.productName ?? 'No name'; |
| // Erase not translated categories (e.g. "en:cake"). | ||
| categories = categories.where((c) => !c.startsWith(RegExp('\w+:'))); | ||
| // Erase not translated categories (e.g., "en:cake"). | ||
| categories = categories?.where((c) => !c.startsWith(RegExp(r'\w+:'))).toList(); |
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.
| categories = categories?.where((c) => !c.startsWith(RegExp(r'\w+:'))).toList(); | |
| categories = categories.where((c) => !c.startsWith(RegExp(r'\w+:')) |
| // Set updated German categories AND avoid erasure of the not translated ones. | ||
| product.categoriesTagsInLanguages?[OpenFoodFactsLanguage.GERMAN] = | ||
| (updatedTranslatedCategories ?? []) + notTranslatedCategories; |
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.
| (updatedTranslatedCategories ?? []) + notTranslatedCategories; | |
| updatedCategories + notTranslatedCategories; |
What