Skip to content

Conversation

@thijskh
Copy link
Member

@thijskh thijskh commented Sep 3, 2021

Reimplement getPreferredTranslation outside of IdPDisco so it's reusable and much more complete. The new method will search the current, default and fallback language for a displayable string in various metadata fields. This should be much more complete and robust than previous approches. Make it a Twig filter so it can also be used there.

For clarity:

  • translateFromArray method/filter will give a single entry for an array with multiple language options. Most useful with e.g. config file options that have this format.
  • getEntityPropertyTranslation method/filter will walk the three languages in priority order to find a named metadata key (useful for localized metadata fields where no other fields need to be searched)
  • getEntityDisplayName (method only fornow) for the specific case for displaying the name, where besides different languages we also search different metadata fields.

If the approach is deemed OK there are some other places in the code where we can use this so we have a consistent algorithm across the code to find the name of some entity to display.

Reimplement getPreferredTranslation outside of IdPDisco so it's reusable
and much more complete. The new method will search the current, default
and fallback language for a displayable string in various metadata
fields. This should be much more complete and robust than previous
approches. Make it a Twig filter so it can also be used there.
@thijskh
Copy link
Member Author

thijskh commented Sep 3, 2021

Would help to close #460

Used in simplesamlphp/simplesamlphp-module-discopower#10

@thijskh
Copy link
Member Author

thijskh commented Sep 3, 2021

There's also some related stuff only used in IFrameLogout. Is IFrameLogout something still relevant in 2021?

@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #1512 (935f4bc) into master (e89b848) will increase coverage by 0.27%.
The diff coverage is 93.54%.

@@             Coverage Diff              @@
##             master    #1512      +/-   ##
============================================
+ Coverage     40.51%   40.79%   +0.27%     
+ Complexity     3503     3501       -2     
============================================
  Files           142      142              
  Lines         10501    10498       -3     
============================================
+ Hits           4255     4283      +28     
+ Misses         6246     6215      -31     

@tvdijen
Copy link
Member

tvdijen commented Sep 3, 2021

There's also some related stuff only used in IFrameLogout. Is IFrameLogout something still relevant in 2021?

I'm not sure, I don't so SLO myself... Maybe just leave it as is for now?

@thijskh
Copy link
Member Author

thijskh commented Sep 4, 2021

I've looked into languages[priorities]. There's an issue with it. It is only used in translateFromArray(). If you ask me that means it does not deliver upon it's promise by far. That is, such priorities are only used in the few contexts where specifically translateFromArray is used (which is not in many places). (There's also the fact that it's the only member of the language config array. But that's minor.)

I see two options:

  1. Actually implement language priorities across our translation system (at some point?).
  2. Do away with the config option. It does make the already extensive language options quite a bit simpler. And would we really lose a lot of value?

@tvdijen
Copy link
Member

tvdijen commented Sep 4, 2021

Agreed to go with 2. The only reason to fall back to another language is when the translations for the current language are incomplete.. I'd rather put some effort in completing the translations for all languages.

We could use it everywhere, but it's better to reduce the already big
amount of configuration options the admin is confronted with than the
small problem this option solves.
@thijskh thijskh merged commit 13992b1 into master Sep 4, 2021
@thijskh thijskh deleted the feature/getpreferredtranslation branch September 4, 2021 18:35
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants