Skip to content

Conversation

@teolemon
Copy link
Member

What

  • docs: Update DOCUMENTATION.md

language: OpenFoodFactsLanguage.GERMAN,
fields: [ProductField.NAME]
);
final product = await OpenFoodAPIClient.getProductV3(conf);
Copy link
Member Author

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';
Copy link
Member Author

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();
Copy link
Member Author

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(
Copy link
Member Author

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';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(updatedTranslatedCategories ?? []) + notTranslatedCategories;
updatedCategories + notTranslatedCategories;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants