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

Force specific language? #115

Closed
sfieux opened this issue Jun 8, 2017 · 5 comments
Closed

Force specific language? #115

sfieux opened this issue Jun 8, 2017 · 5 comments
Milestone

Comments

@sfieux
Copy link

sfieux commented Jun 8, 2017

I'm trying to force the use of english for my installation of self-service-password. It seems that this piece of code from index.php is causing my trouble:

require_once("conf/config.inc.php"); # contains line $lang ="en"; 
(...)
$lang = detectLanguage($lang, $languages);
require_once("lang/$lang.inc.php");

The way I understand it is: the language is defined in config.inc.php, and afterwards this information is discarded to read it from browser settings in detectLanguage.

Am I missing something?

If I'm not, would you be interested in a PR to change this behaviour? I would change the default language value to "auto" in config.inc.php and only try to detect the browser language if the value is different:

if ( $lang == "auto" ) {
    $lang = detectLanguage($lang, $languages);
}
require_once("lang/$lang.inc.php");
if (file_exists("conf/$lang.inc.php")) {
    require_once("conf/$lang.inc.php");
}
@coudot
Copy link
Member

coudot commented Jun 8, 2017

Maybe the best would be to configure a list of authorized languages. Then this would require a new parameter which will be an array. If it is empty, all available languages will be authorized, else this parameter will be used to limit which languages could be used.

@sfieux
Copy link
Author

sfieux commented Jun 8, 2017

What would be the expected behaviour when several languages are authorized but the detected one is not part of the list? Une the first authorized one? Use initial $lang value?

@coudot
Copy link
Member

coudot commented Jun 8, 2017

if the lang is not one authorized, then fall back to default lang

@plewin
Copy link
Member

plewin commented Jul 4, 2017

I'm closing this issue because the PR was merged.
Thank you for your contribution @sfieux.

@plewin plewin closed this as completed Jul 4, 2017
@sfieux
Copy link
Author

sfieux commented Jul 5, 2017

No problem, I'm the one who needed it :)

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

No branches or pull requests

3 participants