Skip to content

Conversation

@webdevinition
Copy link
Contributor

Hello @jbtronics,

In relation to #1051 the feature custom data source synonyms / labels.
Also mentioned in the discussion under #1041, section 1.

A preferred language selection and a configuration option for data source synonyms for the Part DB data sources were created under the System Settings. The data source synonym system is intended to display user-friendly and use-case-related names for data sources – for example, in the sidebar/treeview – and ultimately to "personalize" them.

In the future I would add this to the Part-DB-project following the integration, analogous for assemblies (a feature PR for this will follow), and users can then decide how to visually name the data sources for assemblies also.
I have therefore initially left out assemblies as a data source consideration in this PR, as I will divide this into separate PRs.

2025-10-15-System settings for preferred languages and custom data source synonyms 2025-10-15-Custom data source synonyms in treeview

Thanks for everything so far! I am grateful for integration!

Best regards,
Marcel

@jbtronics
Copy link
Member

I finally found time to take a look at your PR.
Personally, I don't really have much use for it, but i can see how this might be beneficial for some people.

However, some smaller things should be fixed before merging:

  • I have implemented the whole "preferred languages" thing independently before I saw this PR. So that part of the PR is basically obsolete and can be removed
  • I do not really like that the translations need to be supplied as raw JSON code. It should be quite easy to implement a collection type with subfields for language selection and translation, which should improve UX and make it less error-prone
  • As the functionality to retrieve the actual label for the data sources will be used quite often, this should be centralized in its own service. And for easy usage in twig, there should be a custom twig function for this. This will probably also make the templates easier to read and easier to use the customized labels later...

Marcel Diegelmann added 3 commits November 4, 2025 08:23
Die Spracheinstellungen/System-Settings wurden um die Möglichkeit ergänzt, bevorzugte Sprachen für die Dropdown-Menüs festzulegen. Zudem wurde ein Datenquellen-Synonymsystem implementiert, um benutzerfreundlichere Bezeichnungen anzuzeigen und zu personalisieren.
Die Verwaltung der Datenquellen-Synonyme wurde überarbeitet, um ein flexibleres und strukturiertes Konzept zu ermöglichen. Der bestehende JSON-basierte Ansatz wurde durch eine neue Service-basierte Architektur ersetzt, die eine bessere Handhabung und Erweiterbarkeit erlaubt.
@webdevinition webdevinition force-pushed the feature/custom-data-source-label branch from 7c24e18 to a8b3dce Compare November 5, 2025 13:18
@webdevinition
Copy link
Contributor Author

@jbtronics,

I have implemented the whole "preferred languages" thing independently before I saw this PR. So that part of the PR is basically obsolete and can be removed

Okay, that must have been a timing overlap. I've reverted my expansions accordingly :)

I do not really like that the translations need to be supplied as raw JSON code. It should be quite easy to implement a collection type with subfields for language selection and translation, which should improve UX and make it less error-prone

You are absolutely right! I have made the necessary additions and hope that it now comes closer to your constructive suggestions!

As the functionality to retrieve the actual label for the data sources will be used quite often, this should be centralized in its own service. And for easy usage in twig, there should be a custom twig function for this. This will probably also make the templates easier to read and easier to use the customized labels later...

I've written a service here that's already being used in the dependent Twig helper or the TreeViewGenerator, for example. I've also added a distinction / input option for singular- / plural-translations. This means it can be used in other places in the future. I hope this will be useful in the future :)

2025-11-05-Datasource translation via collection

Collection input option

Thank you so much for your work – also for the pull requests that have already been accepted!

Best regards,
Marcel

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 44.72843% with 173 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.40%. Comparing base (e53b72a) to head (e49048b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Form/Settings/TypeSynonymsCollectionType.php 0.00% 106 Missing ⚠️
src/Form/Settings/TypeSynonymRowType.php 0.00% 60 Missing ⚠️
src/Services/ElementTypeNameGenerator.php 88.00% 3 Missing ⚠️
src/Services/ElementTypes.php 97.18% 2 Missing ⚠️
src/Controller/SettingsController.php 0.00% 1 Missing ⚠️
...egisterSynonymsAsTranslationParametersListener.php 95.45% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1079      +/-   ##
============================================
- Coverage     58.70%   58.40%   -0.31%     
- Complexity     7173     7275     +102     
============================================
  Files           574      579       +5     
  Lines         22892    23147     +255     
============================================
+ Hits          13438    13518      +80     
- Misses         9454     9629     +175     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbtronics jbtronics merged commit 54f318e into Part-DB:master Nov 12, 2025
13 of 14 checks passed
@jbtronics
Copy link
Member

I changed some things about the PR (in a way that you will need to redefine the synonyms):

  • I made the synonym system far more universal, so that you can now define synonyms for all of Part-DB element types
  • I unified everything synonym related into the ElementTypeNameGenerator that was already existing and is used to programmatically get the labels for element types
  • New, shorter twig functions
  • Improved UI for the settings
  • And what is probably the most useful and important things to allow to use the synonyms in other places, is that the synonyms can be used inside translations. So instead of manually inserting the code to retrieve the synonym for something, you can just use a placeholder inside a translation.

So if you have defined a translation like "Create new [category]" it will become "Create new category" if you have no synonym defined, and "Create new my synonym" if there is a custom type synonym defined.

The type values can be found inside the ElementTypes enum. For every type there are 4 placeholders/versions defined:

  • {category}: Singular with capital letter (e.g. "Category")
  • {{category}}: Plural with capital letter (e.g. "Categories")
  • [category]: Singular lowercase (e.g. "category")
  • [[category]]: Plural lowercase (e.g. "categories")

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants