Translation and cache conflict

Created on 3 June 2023, about 1 year ago
Updated 18 July 2023, 12 months 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

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

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

  • 🇹🇷Turkey Orkut Murat Yılmaz

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

  • 🇹🇷Turkey Orkut Murat Yılmaz

    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

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

Production build 0.69.0 2024