Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forced Lang #61

Open
JordanMontel opened this issue Jul 16, 2018 · 1 comment
Open

Forced Lang #61

JordanMontel opened this issue Jul 16, 2018 · 1 comment

Comments

@JordanMontel
Copy link

The documentation says :

$i18n->setForcedLang('en'); // force english, even if another user language is available

But in i18n.class.php the variable $forcedLang is never used.

Maybe in the init() function you should test if this variable is not null ? And use it if the user set it ?

Something like

        // search for language file
        $this->appliedLang = NULL;
        if ($this->forcedLang == NULL) {
            foreach ($this->userLangs as $priority => $langcode) {
                $this->langFilePath = $this->getConfigFilename($langcode);
                if (file_exists($this->langFilePath)) {
                    $this->appliedLang = $langcode;
                    break;
                }
            }
        } else {
            $this->langFilePath = $this->getConfigFilename($this->forcedLang);
            if (file_exists($this->langFilePath)) {
                $this->appliedLang = $this->forcedLang;
            }
        }
@Philipp15b
Copy link
Owner

If a forced language is set, then the getUserLangs method should include it in its return value and the forced language should be tried first. However, if the forced language does not exist, then the next choice will be tried. Maybe this is a bit unintuitive. Does the language file for the forced language exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants