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

Months are displayed in the wrong language in the search #132

Closed
Fraenkiman opened this issue Jul 18, 2022 · 3 comments
Closed

Months are displayed in the wrong language in the search #132

Fraenkiman opened this issue Jul 18, 2022 · 3 comments
Labels

Comments

@Fraenkiman
Copy link
Collaborator

Hello, everyone,

in the search (search.php) when selecting the month instead of the selected default language; in my case German, the month is displayed in English.

suche-sprache

Best Regards

@azett azett added the i18n label Aug 11, 2022
@azett
Copy link
Member

azett commented Aug 14, 2022

Not as simple as it seems: Month names are generated by Smarty automatically...

fp-interface/sharedtpls/search.tpl:
<p>{html_select_date month_names=$monthnames start_year=2000 end_year=$smarty.now|date_format:"%Y" field_separator=" - " field_order="DMY" time="0000-00-00" all_empty="--"}</p>

@Fraenkiman
Copy link
Collaborator Author

Hello, everyone,

laborix has created a possible solution in this forum post. Perhaps one can accommodate the PHP8.1 compatible with.
However, I haven't had a chance to test the solution yet

Best Regards

@Fraenkiman
Copy link
Collaborator Author

Fraenkiman commented Sep 27, 2022

Hello, everyone,

laborix from our FlatPress forum created a working solution in the post.

The Smarty module function.html_select_date.php must be adjusted as follows:

Replace the lines 190 - 193 in the file "/fp-includes/smarty/plugins/function.html_select_date.php"

for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
  $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}

with this code:

/*
 * Flatpress issue #132
 * Months are displayed in the wrong language in the search
 *
 * Debug: 2022-09-27 
 * Using now the month_names from the Flatpress language files
 */
global $lang;
    
$replace_month_names = array();
$replace_month_names[0] = '-';
$replace_month_value_format = array("00","01","02","03","04","05","06","07","08","09","10","11","12");
$fp_lang_months = array();
$fp_lang_months = $lang['date']['month'];
$fplm = 0;
for ($lm = 1; $lm <= 12; $lm++) {      
  $replace_month_names[$lm] = $fp_lang_months[$fplm];
  $fplm++;
}
for ($i = 1; $i <= 12; $i++) {
  $month_names[$i] = $replace_month_names[$i];
  $month_values[$i] = $replace_month_value_format[$i];
}

The correct search results should now appear (tested with FlatPress 1.2.1 under PHP 8.0) and run under PHP 7.x, as well as PHP 8.0 and PHP 8.1.

I also tested the solution using FlatPress fp-1.3.dev [master] - and it works very well, as expected.

Best regards and have a restful night

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

No branches or pull requests

2 participants