Hi

Old token format is flooding translation table with numerous source strings.

I can see hundreds of unnecessary source strings added to locales_source table by Views Conditional module.

Examples:

This is my string number 1
This is my string number 2
This is my string number 3
...

The reason could be that Views Conditional module is using Drupal 7 format of tokens [token] instead of new format tokens {{ token }} recommended for Drupal 8. So, system can not recognize string This is my string number [token] as one string with pattern "This is my string number @token". Instead old-fashioned tokens are replaced with it's values and all these newly generated strings are added to locales_source table as unique source strings.

Changing token shape to new {{ token }} format will probably fix this problem.

To reproduce:

1. Create multilingual site
2. Create view page with conditional field
3. Use some tokens in "Then output this..." and "Otherwise, output this..." sections. For example: Some text [title]
4. Visit view page
5. Go to /admin/config/regional/translate and search for "Some text".

You will find many source strings created by Views Conditional module:

Some text Some title 1
Some text Some title 2
Some text Some title abc
...

Comments

devad created an issue. See original summary.

devad’s picture

Title: Old token format and flooding translation table with hundreds of source strings » Old token format is flooding translation table with numerous source strings
anand.toshniwal93’s picture

Assigned: Unassigned » anand.toshniwal93
anand.toshniwal93’s picture

Assigned: anand.toshniwal93 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.66 KB
anand.toshniwal93’s picture

StatusFileSize
new1.65 KB

Re-rolled patch in comment 4.

devad’s picture

Title: Old token format is flooding translation table with numerous source strings » Old token format should be updated to new Drupal 8 format
Issue summary: View changes

Hi @anand.toshniwal93. Thnx for patch!

I have applied it manually and it works nicely.

However, existing views conditional fields in views are broken when patch is applied. They have to be updated manually to new token format which is probably not the best solution.

I suppose that there should be some kind of update path which will ensure that existing views conditional fields in views are updated from old Drupal 7 [token] format to new Drupal 8 {{ token }} format.

So, I am not sure if I should change Status to RTBC or to "Needs work". :)

Changing issue title to better fit the topic.

navneet0693’s picture

Title: Old token format should be updated to new Drupal 8 format » Old token format is flooding translation table with numerous source strings
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
navneet0693’s picture

Title: Old token format is flooding translation table with numerous source strings » Old token format should be updated to new Drupal 8 format
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

@All,

Accidentally submitted without refreshing the page. Reverting changes and setting to 'Needs Work'

devad’s picture

I have just realized that 8.x branch is in .dev version still.

Drupal is reporting about 250 sites using 8.x-dev version of Views Conditional module currently which is not so huge amount.

If making update path would be complicated... maybe it would be better to commit the patch (maybe release an alpha1 version), and add a release note for all users upgrading from previous .dev that existing Views Conditional fields (with tokens) need to be manually updated after upgrade.

Existing Views Conditional fields without tokens will not need manual update, so I suppose affected users will be much less than 250.

For modules in .dev version committing patches without upgrade path is acceptable... I suppose.

Of course, providing update path would be the best practice... however, if such a task would block this patch commit for a long time... than committing with release note would be better IMHO.

navneet0693’s picture

Status: Needs work » Reviewed & tested by the community

@devad Right, when modules are in dev version, maintainers aren't suppose to provide with an update patch, as it is understandable that the module is in dev state.

  • anand.toshniwal93 committed 9417f00 on 8.x-1.x
    Issue #2926526 by anand.toshniwal93: Old token format should be updated...
anand.toshniwal93’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all :)

I have created the alpha release which now includes this change.

Mike Dodd’s picture

StatusFileSize
new1.91 KB

This has been applied to the latest dev release as well as the staging release..

attached a patch to stop old tokens breaking. Only need this is dev branch i guess...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

devad’s picture

@Mike Dodd #13

Regarding patch #13 - it would be better to encourage users to manually edit their existing views to D8 token format than to apply patch #13 and keep old token formats in their views.

Old token format is not supposed to be used with D8 as it can cause various issues in multilingual sites (as explained in this issue summary) and probably other issues as well.