Translation and cache conflict

Created on 3 June 2023, over 1 year ago
Updated 18 July 2023, over 1 year ago

Hello all,

Problem/Motivation

When I change the interface language, I need to clear the cache every time, in order to see the translations.

Steps to reproduce

Create a bundle with 2 or more layers
Create translation for each layer name
Change the interface language with Drupal's language switcher

Layer names on overlay controls stays same. After clearing the cache, you can see the translations, but after switching languages, you need to clear cache again.

What could be the reason of this issue?

Best,
Orkut

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

🇹🇷Turkey orkut murat yılmaz Istanbul

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @orkut murat yılmaz
  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    Problem still remains, even when I turn the view cache off.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    I've also tried to cache setting as tag based, it didn't work either.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    I've solved my problem with Asset Injector module.

    After installing the module, I've added a JS Injector with a relevant name and the code below:

    function replaceText(searchTextArray, replacementTextArray) {
      const textNodes = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
    
      while (textNodes.nextNode()) {
        const node = textNodes.currentNode;
        let nodeText = node.nodeValue;
    
        for (let i = 0; i < searchTextArray.length; i++) {
          const searchText = searchTextArray[i];
          const replacementText = replacementTextArray[i];
    
          if (nodeText.includes(searchText)) {
            nodeText = nodeText.replaceAll(searchText, replacementText);
          }
        }
    
        node.nodeValue = nodeText;
      }
    }
    
    document.addEventListener("DOMContentLoaded", function() {
      const searchTextArray = ["Original Layer Name 1", "Translation of Layer Name 1"];
      const replacementTextArray = ["Original Layer Name 2", "Translation of Layer Name 2"];
    
      replaceText(searchTextArray, replacementTextArray);
    });

    After setting the conditions, saved the JS injector and flushed the cache.

    Until this conflict is solved, this quick and dirty solution might help.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    I've also installed the leaflet's latest dev version, but the problem remained. I'm adding the related issue too.

Production build 0.71.5 2024