I'm using a Wordpress 5.2.4 installation on a FreeBSD Server 11.3-RELEASE-p7. On my Website I need to output the German name of the weekday from certain dates stored in a MySQL-Database. Retrieving the values from the database and converting it into the name of weekday works without issues, for English that is. The formatting of the date itself works without issues (from YYYY-MM-DD to DD.MM.YYYY).
The Problem
As mentioned before, I can't change the language used for the output of the weekday name.
What I've tried
I've tried various solutions popping up from google search. Including changing the Language-Settings of Wordpress-installation in General -> Settings (which didn't help ofc). Here's just a selection of strings I expected to work:
foreach($result_dates as $date){
setlocale(LC_TIME, 'de_DE.utf8'); //'de_DE@euro', 'de_DE', 'deu_deu',
setlocale(LC_ALL, 'de_DE.utf8'); //'de_DE@euro', 'de_DE', 'deu_deu',
$day = strftime("%A", strtotime($date->start_date));
$date_formatted = date("d.m.Y", strtotime($date->start_date));
echo '
<div class="row">
<div class="col-sm-12 col-12">
<h3> <span id="day-long">' . $day . '</span>, <span id="day-short">' . strftime($date_formatted) . '</span></h3>
</div>
</div> ...';
}
Using the methodes suggested I run the following commands, with a confusing output:
echo setlocale(LC_ALL, 0); // output: C
... and ...
echo setlocale(LC_ALL, NULL); //output: C
$locale_info = localeconv();
print_r($locale_info); //output: Array ( [decimal_point] => . [thousands_sep] => [int_curr_symbol] => [currency_symbol] => [mon_decimal_point] => [mon_thousands_sep] => [positive_sign] => [negative_sign] => [int_frac_digits] => 127 [frac_digits] => 127 [p_cs_precedes] => 127 [p_sep_by_space] => 127 [n_cs_precedes] => 127 [n_sep_by_space] => 127 [p_sign_posn] => 127 [n_sign_posn] => 127 [grouping] => Array ( [0] => 127 ) [mon_grouping] => Array ( [0] => 127 ) )
What am I looking for?
I would like a simple working solution usind the setlocale()
in combination with strftime()
. Of course there is the possibility of making a manual translation using an array comparison and str_replace()
. But I am sure, that it is possible without those workaround-solutions.
The hint from @nbari pointed me to the right direction. After activating ssh-access and downloading putty I ran the following command on CLI:
locale -a
The command returned a list of all installed language packages. German was preinstalled, but instead of de_DE.utf8
it was called de_DE.UTF8
(note the uppercase on the encoding). That fixed it for me. Thanks!