change from default language to locale for the unlogged

Started by Naytheet, October 18, 2022, 11:30:28 AM

Previous topic - Next topic

Naytheet

Hello, does SMF handle this, was this discussed earlier or do I have to code a solution for it?

I want the theme language to default the visitor's country language, or english if not available.
In me sanitas et robur

Diego Andrés

I don't think that's an option at the moment.
Plus, you'd have to download/install all of the available language files and keep them up to date (not all of the translations are finished in Crowdin).

SMF Tricks - Free & Premium Responsive Themes for SMF.

Naytheet

I'm not gonna handle all the translations, but just two. Ok well I'll deal with that answer then, but I thought someone already did sth for that.
In me sanitas et robur

Aleksi "Lex" Kilpinen

IMHO, for just 2 languages you really don't want or need language detection that will commonly end up giving you trouble anyways. I would suggest the easiest solution to maintain would be something like adding small flag icons to your index template and linking them to languages - something like

🇫🇮 - 🇺🇸
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Naytheet

Sure, that always helps to instantly display the page in the preferred language though, so the newcomers won't run away as soon as they enter.

in Settings.php :

/**
 * The default language file set for the forum.
 *
 * @var string
 */

// I would just have to change it here :
$language = 'english';

And $_SERVER['HTTP_ACCEPT_LANGUAGE'] that will let us manage to choose it. Then modifying the mod file will have to take care of propagating the changes through the themes and updates I guess.
In me sanitas et robur

Aleksi "Lex" Kilpinen

Quote from: Naytheet on October 19, 2022, 12:04:35 PMSure, that always helps to instantly display the page in the preferred language though, so the newcomers won't run away as soon as they enter.
You know, could do without the attitude. I was offering an honest suggestion that would be less involved, less error prone, and commonly done on websites all around - But have it your way, you seem to know better.
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Steve

*ouch* ... it takes a lot to upset the Project Manager. Maybe a language barrier issue? Or should I just stay out of this?
DO NOT pm me for support!

Aleksi "Lex" Kilpinen

Could also be I was just a wee tired and touchier than usual, but still - It is responses like that one, that end up tiring people honestly wanting to help. It's a thankless enough job many times as it is.

There have been many different approaches to user selectable languages in SMF. Icons, dropdowns, multi-language mods.
I don't think anything like what is asked here has been made, and from personal experience I can tell you that I absolutely hate it when websites show me contents in Swedish, only because I work for a company based in Sweden, when I don't actually speak Swedish. That is what makes me run away as soon as I enter.
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Naytheet

Quote from: Aleksi "Lex" Kilpinen on October 20, 2022, 02:21:55 AMCould also be I was just a wee tired and touchier than usual, but still - It is responses like that one, that end up tiring people honestly wanting to help. It's a thankless enough job many times as it is.

There have been many different approaches to user selectable languages in SMF. Icons, dropdowns, multi-language mods.
I don't think anything like what is asked here has been made, and from personal experience I can tell you that I absolutely hate it when websites show me contents in Swedish, only because I work for a company based in Sweden, when I don't actually speak Swedish. That is what makes me run away as soon as I enter.

That's where $_SERVER['HTTP_ACCEPT_LANGUAGE'] comes instead of that new geoip_country_code_by_name() which upsets you and doesn't work for me because I have to install more PHP plugin stuff.
In me sanitas et robur

Naytheet

Quote from: Naytheet on October 19, 2022, 12:04:35 PMSure, that always helps to instantly display the page in the preferred language though, so the newcomers won't run away as soon as they enter.

in Settings.php :

/**
 * The default language file set for the forum.
 *
 * @var string
 */

// I would just have to change it here :
$language = 'english';

And $_SERVER['HTTP_ACCEPT_LANGUAGE'] that will let us manage to choose it. Then modifying the mod file will have to take care of propagating the changes through the themes and updates I guess.

Edit : propagation doesn't apply to settings, so it's easy. I just have to modify this file like this :
/**
 * The default language file set for the forum.
 *
 * @var string
 */
$language = 'english';
// english by default, french or spanish according to the client's header
switch (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) {
    case "fr":
        $language = 'french';
        break;
    case "es":
        $language = 'spanish';
        break;
}
That doesn't deal with the "q" variable, to avoid to make it a lil heavy too much. Thanks for the help.
In me sanitas et robur

Advertisement: