Leuchtfeuer / locate

The users country and preferred language and other facts will be detected. Depending on configurable rules the user can be redirected to other languages or pages. New functionality can be added easily.
https://www.Leuchtfeuer.com
GNU General Public License v2.0
9 stars 14 forks source link

First judge is always used regardless of preferred language set in browser #59

Open gpazout opened 3 days ago

gpazout commented 3 days ago

No matter what I do the extension always picks the first judge, no matter the preferred language set in the browser. Because of this, the extension redirects to the Chinese page even though users do not have Chinese in their preferred languages!

I have the following languages on my website:

For testing, I have the following preferred languages set in my browser (Chrome) in the following order (1 being the top priority)

  1. Russian
  2. German

The configuration of the verdicts and judges looks like this:

# TABLE: sys_language
#
# | uid | title     | flag | language_isocode |
# ---------------------------------------------
# |  1  | English   | en   | en               |
# |  2  | Chinese   | cn   | zh               |
# |  3  | Russisch  | ru   | ru               |
# |  4  | Arabisch  | sa   | ar               |
# |  5  | Deutsch   | de   | de               |

# verdicts
config.tx_locate {
    sessionHandling = 1
    overrideSessionValue = 1

    verdicts {
        # Redirect the user to the default language version of the current page
        redirectToPageEN = Leuchtfeuer\Locate\Verdict\Redirect
        redirectToPageEN {
            sys_language = 1
        }

        redirectToPageDE = Leuchtfeuer\Locate\Verdict\Redirect
        redirectToPageDE {
            sys_language = 5
        }

        redirectToPageCN = Leuchtfeuer\Locate\Verdict\Redirect
        redirectToPageCN {
            sys_language = 2
        }

        redirectToPageRU = Leuchtfeuer\Locate\Verdict\Redirect
        redirectToPageRU {
            sys_language = 3
        }

        redirectToPageDEFAULT = Leuchtfeuer\Locate\Verdict\Redirect
        redirectToPageDEFAULT {
            sys_language = 0
        }
    }
}
# judges
config.tx_locate.judges {    

    # chinese
    30 = Leuchtfeuer\Locate\Judge\Condition
    30 {
        verdict = redirectToPageCN
        fact = browserAcceptLanguage
        prosecution = cn
    }

    # russian
    40 = Leuchtfeuer\Locate\Judge\Condition
    40 {
        verdict = redirectToPageRU
        fact = browserAcceptLanguage
        prosecution = ru
    }

    # german
    100 = Leuchtfeuer\Locate\Judge\Condition
    100 {
        verdict = redirectToPageDE
        fact = browserAcceptLanguage
        prosecution = de
    }

    # english
    300 = Leuchtfeuer\Locate\Judge\Condition
    300 {
        verdict = redirectToPageEN
        fact = browserAcceptLanguage
        prosecution = en
    }

    # default language
    999999 = Leuchtfeuer\Locate\Judge\Fixed
    999999.verdict = redirectToPageDEFAULT
}
gpazout commented 3 days ago

It seems like the configuration of the "facts" was missing


#facts
config.tx_locate.facts {
    browserAcceptLanguage = Leuchtfeuer\Locate\FactProvider\BrowserAcceptedLanguage
    countryByIP = Leuchtfeuer\Locate\FactProvider\IP2Country
}