Quote
Scalony z 07 February 2022 21:57:45:
setlocale()
- this is another function that tells php which translation to use from the server. Here is the locale string that was used to control which translations are used in strftime()
https://github.com/PHPFusion/PHPFusio...bal.php#L2 but now can be removed since it doesn't work and strftime() was completely removed in core.function format_date($format, $time) {
global $locale, $settings;
$format = str_replace(
['%a', '%A', '%d', '%e', '%u', '%w', '%W', '%b', '%h', '%B', '%m', '%y', '%Y', '%D', '%F', '%x', '%n', '%t', '%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X', '%z', '%Z', '%c', '%s', '%%'],
['D', 'l', 'd', 'j', 'N', 'w', 'W', 'M', 'M', 'F', 'm', 'y', 'Y', 'm/d/y', 'Y-m-d', 'm/d/y', "n", "t", 'H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s', 'O', 'T', 'D M j H:i:s Y', 'U', '%'],
$format
);
$date = DateTimeImmutable::createFromFormat('U', $time);
if ($settings['locale'] == 'English') {
return $date->format($format);
} else {
$_months_en = " |January|February|March|April|May|June|July|August|September|October|November|December";
$exp_months_en = explode("|", $_months_en );
$exp_settings_locale = explode("|", $locale['months']);
$date_lang = str_replace($exp_months_en, $exp_settings_locale, $date->format($format));
return $date_lang;
}
}
global
variables.. In v8/v9 define em with $locale = fusion_get_locale();
function format_date($format, $time) {
$locale = fusion_get_locale();
$settings = fusion_get_settings();
$format = str_replace(
['%a', '%A', '%d', '%e', '%u', '%w', '%W', '%b', '%h', '%B', '%m', '%y', '%Y', '%D', '%F', '%x', '%n', '%t', '%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X', '%z', '%Z', '%c', '%s', '%%'],
['D', 'l', 'd', 'j', 'N', 'w', 'W', 'M', 'M', 'F', 'm', 'y', 'Y', 'm/d/y', 'Y-m-d', 'm/d/y', "n", "t", 'H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s', 'O', 'T', 'D M j H:i:s Y', 'U', '%'],
$format
);
$date = DateTimeImmutable::createFromFormat('U', $time);
if ($settings['locale'] != "English") {
// Replacer arrays
$search_months_long = " |January|February|March|April|May|June|July|August|September|October|November|December";
$search_months_short ="&nbps;|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sept|Oct|Nov|Dec";
$search_weekdays_long = "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday";
$search_weekdays_short = "Sun|Mon|Tue|Wed|Thu|Fri|Sat";
if (IsSet($locale['shortweekdays'])) {
$search = explode("|", ($search_months_long."|".$search_months_short."|".$search_weekdays_long."|".$search_weekdays_short));
$replace= explode("|", ($locale['months']."|".$locale['shortmonths']."|".$locale['weekdays']."|".$locale['shortweekdays']));
}
else {
$search = explode("|", ($search_months_long."|".$search_months_short."|".$search_weekdays_long));
$replace= explode("|", ($locale['months']."|".$locale['shortmonths']."|".$locale['weekdays']));
}
return str_replace($search, $replace, $date->format($format));
}
else {
return $date->format($format);
}
}
$locale['shortweekdays'] = "Sun|Mon|Tue|Wed|Thu|Fri|Sat";
Category Forum
Locales Forum - 9Labels
None yet
Statistics
4 participants
Notifications
You are not receiving notifications from this thread.
Related Questions