Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be nice to have an option to chose between language native name and language code when we display the link output.
Comment | File | Size | Author |
---|---|---|---|
#3 | languageicons-add-langauge-code-option-2865704.patch | 2.7 KB | daniel.matcau |
Issue fork languageicons-2865704
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
daniel.matcau CreditAttribution: daniel.matcau commentedComment #3
daniel.matcau CreditAttribution: daniel.matcau as a volunteer commentedHere is the patch to allow language code on display. This is working with core Language switcher.
Comment #4
undersound3 CreditAttribution: undersound3 commented+1 patch works fine, thanks
Comment #5
pfrenssenThanks for proposing this useful option! I reviewed the code:
Global constants are no longer allowed in the Drupal 8 coding standards. These should be moved into a class or interface. I suppose the
LanguageiconsAdminSettings
class is the perfect choice since it is the only class in the entire module. Normally it is not considered best practice to make public constants available inside a form class, but it would be overkill to introduce an interface just for this.Also let's not use magic numbers for these options, let's use human readable strings like
native
andlangcode
so that site builders can make sense of the options when they are reading the config YML files.It makes it a bit more difficult since the Drupal form builder expects numbers for select dropdowns and not string keys, but perhaps we can solve this by enumerating the options in a single constant like this?
According to coding standards we have to use the short array syntax
[]
instead ofarray()
.This new config key
display_format
needs to be added to the schema inconfig/schema/languageicons.schema.yml
.Comment #6
AnybodyI like this idea and I'm maintainer now. Could someone prepare a MR for review?
Comment #9
roshni27 CreditAttribution: roshni27 at Valuebound for Valuebound commentedHello ,
I have applied patch #3 on 8.x-1.x and 2.x but it does not apply cleanly.
I have implement the language code by referencing #3 and #5 comment.
Please review the MR.
If any mistake please guide me.
Thanks
Comment #10
Wassilissa Elrich CreditAttribution: Wassilissa Elrich at publicplan GmbH commentedI tested the issuse fork and it was successful.
Comment #11
pfrenssenThanks for the great work on this!
I had a look at the merge request. It looks good, but we are adding a new option to the configuration, so this also needs a config schema update and a simple post-update hook to set the default value for existing installations.
Comment #12
pfrenssenUpdated the config schema and provided an update hooks, and did some minor cleanup. I have not tested my changes.
Comment #13
AnybodyThanks all, looking really good!
@pfrenssen I might be wrong, but shouldn't "simple" config updates like this use regular update hooks?
See https://www.specbee.com/blogs/update-and-post-update-hooks-for-successfu...
Comment #14
pfrenssenI'm always confused about this. According to the documentation, config updates are supported in
hook_update_N()
, but I always thought it is best practice to only use those for data model updates nowadays. I saw a bunch of config updates in the post-update hooks of the core system module so I went with that. E.g.system_post_update_service_advisory_settings()
I guess both work. If you want I can change it.
Comment #15
Anybody@pfrenssen all good, I'm totally fine with that and I'm also confused, what's the right way ... we can keep it like this.
So only needs final testing?