View Issue Details

IDProjectCategoryView StatusLast Update
0010929mantisbtlocalizationpublic2009-10-07 14:19
ReporterDanez Assigned Todhx  
PrioritylowSeveritytweakReproducibilityalways
Status closedResolutionfixed 
PlatformPCOSWindowsOS VersionVista
Product Version1.2.0rc1 
Target Version1.2.0rc2Fixed in Version1.2.0rc2 
Summary0010929: Use localizeable function strftime() instead of date()
Description

In the file /core/date_api.php in function print_month_option_list() you use date('F',...) . This always outputs the month in english regardless which locale is set.

Steps To Reproduce

To reproduce switch to something other then english and use the month-selectbox in the date-filter on the view issue page.

Additional Information

It would be better to use strftime (http://php.net/strftime) in conjunction with setlocale (http://php.net/setlocale).
I think the problem is that mantis saves the language by name(german) and not by locale(de_DE). Maybe setting a variable in the language files like this:
$locale = array('de_DE.UTF-8','de_DE@euro','de_DE');
An then using that with setlocale().

Tagspatch
Attached Files
strings_english.patch (653 bytes)   
--- strings_english.txt.orig	Sun Sep 13 10:11:50 2009
+++ strings_english.txt	Sun Sep 13 10:11:56 2009
@@ -1601,3 +1601,17 @@
 $s_database_information = 'MantisBT Database Information';
 $s_path_information = 'MantisBT Path Information';
 
+# months
+
+$s_month_january = 'January';
+$s_month_february = 'February';
+$s_month_march = 'March';
+$s_month_april = 'April';
+$s_month_may = 'May';
+$s_month_june = 'June';
+$s_month_july = 'July';
+$s_month_august = 'August';
+$s_month_september = 'September';
+$s_month_october = 'October';
+$s_month_november = 'November';
+$s_month_dezember = 'Dezember';
\ No newline at end of file
strings_english.patch (653 bytes)   
date_api.patch (609 bytes)   
--- date_api.php.orig	Sun Sep 13 10:04:36 2009
+++ date_api.php	Sun Sep 13 10:05:30 2009
@@ -89,9 +89,9 @@
 	for( $i = 1;$i <= 12;$i++ ) {
 		$month_name = date( 'F', mktime( 0, 0, 0, $i, 1, 2000 ) );
 		if( $i == $p_month ) {
-			echo "<option value=\"$i\" selected=\"selected\">$month_name</option>";
+			echo "<option value=\"$i\" selected=\"selected\">" . lang_get( 'month_' . strtolower($month_name)) . "</option>";
 		} else {
-			echo "<option value=\"$i\">$month_name</option>";
+			echo "<option value=\"$i\">" . lang_get( 'month_' . strtolower($month_name)) . "</option>";
 		}
 	}
 }
date_api.patch (609 bytes)   

Activities

Danez

Danez

2009-09-13 04:20

reporter   ~0022909

I thought about it a little bit more and came to the conclusion that using strftime() is still bad, because most don't have all locales installed on their servers.
So it would be better to use date(), but make it translatable.
I attached to patches, one for date_api.php and on for strings_english.txt.

Danez

Danez

2009-09-20 07:44

reporter   ~0022987

Fixed there:
http://git.mantisforge.org/w/mantisbt/dtschinder.git?a=commit;h=ea24023fb5d84f0080ecf57b6f3270869d29fcca

dhx

dhx

2009-09-22 03:36

reporter   ~0023009

Thanks! Committed to 1.2.x as well as 1.3.x because a lack of localisation of the month selection list is a defect that will impact international users.

Related Changesets

MantisBT: master-1.2.x 5f78466f

2009-09-20 07:40

Danez

Committer: dhx


Details Diff
Fix 0010929: Use localizeable function strftime() instead of date()

This commit adds the possibility to translate month names in lang-files.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0010929
mod - lang/strings_english.txt Diff File
mod - core/date_api.php Diff File

MantisBT: master 1ad85ad6

2009-09-20 07:40

Danez

Committer: dhx


Details Diff
Fix 0010929: Use localizeable function strftime() instead of date()

This commit adds the possibility to translate month names in lang-files.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0010929
mod - lang/strings_english.txt Diff File
mod - core/date_api.php Diff File

MantisBT: master-1.2.x 2c505b17

2009-09-22 03:44

dhx


Details Diff
Issue 0010929: Fix typo dezember=>december

There was a typo with the spelling of "December" in commit
1ad85ad6c1276e4ef0632c31637185f62e7e873d
Affected Issues
0010929
mod - lang/strings_english.txt Diff File

MantisBT: master 5814da84

2009-09-22 03:44

dhx


Details Diff
Issue 0010929: Fix typo dezember=>december

There was a typo with the spelling of "December" in commit
1ad85ad6c1276e4ef0632c31637185f62e7e873d
Affected Issues
0010929
mod - lang/strings_english.txt Diff File