Closed Bug 333938 Opened 19 years ago Closed 6 years ago

Needs access to locale info

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: surkov, Assigned: smontagu)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

Win API has function getLocaleInfo() to get info about locale. F.x. it allows to get first day of the week. The first day of the week can be usefull for calendar widget realization. The bug about "first day of the week" supporting is bug 164495. Probably nsILocale/nsILocaleService can be extended to provide additional information about locale. Probably nsIDateTimeFormat can be extended to support "first day of the week" feature. What do you think about the additional functionality?
If the idea doesn't contradict with nsILocale interface purposes then we can extend a list of supported categories and add to nsILocale the method like getInfo(in category string). Though I don't know what kind of locale info does other platforms (not Windows) provide.
*** Bug 345042 has been marked as a duplicate of this bug. ***
Assignee: kairo → surkov.alexander
Status: UNCONFIRMED → NEW
Component: Localization → Internationalization
Ever confirmed: true
Blocks: 327586
Blocks: 164495
Some thoughts after talk with smontagu on irc: We should extend nsILocale interface for "first day of week" getting by following way: interface nsILocale : nsISupports { // existing methods const long FIRST_DAY_OF_WEEK = 0x1; string GetLocaleInfo(in long aInfoType); }
We can also extend this mechanism for bug 252039 and friends.
Blocks: numbers
Simon, what do you think about the following scenario? 1) Extend nsI<OSName>Locale interfaces to GetLocaleInfo() method 2) Implement this method for nsI<OSName>LocaleImpl classes 3) Add GetLocaleInfo() method to nsILocale interface 4) Add member of nsI<OSName>Locale type to nsLocale class (member type should be depended on platform by using ifdefs instruction) 5) Redirect calls of GetLocaleInfo() method of nsLocale to ns<OSName>LocaleImpl. The approach should be not difficult to implement but I guess it's not so fine to like it a lot.
Probably we can add new interface for GetLocaleInfo() method and then nsILocale and nsI<OSName>Locale interface can be inherited from it. It allows to simplify calls redirection.
Attached patch patchSplinter Review
Attachment #253647 - Flags: review?(smontagu)
Status: NEW → ASSIGNED
Comment on attachment 253647 [details] [diff] [review] patch >Index: intl/locale/src/windows/nsIWin32LocaleImpl.cpp >+ // Get OS version >+ OSVERSIONINFO os; >+ os.dwOSVersionInfoSize = sizeof(os); >+ ::GetVersionEx(&os); >+ PRBool isWAPI = VER_PLATFORM_WIN32_NT == os.dwPlatformId && >+ os.dwMajorVersion >= 4; >+ >+#ifndef WINCE // Always use wide APIs on Win CE. >+ if (isWAPI) { >+#endif >+ PRUnichar dataBuffer[80]; >+ len = GetLocaleInfoW(lcid, info, (LPWSTR) dataBuffer, 80); >+ data = dataBuffer; >+#ifndef WINCE // Always use wide APIs on Win CE. >+ } else { >+ char dataBuffer[80]; >+ len = GetLocaleInfoA(lcid, info, (LPSTR) dataBuffer, 80); >+ >+ // convert result to unicode >+ if (len > 0) { >+ len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR) dataBuffer, >+ len, (LPWSTR) data, 80); >+ } >+ } >+#endif Please, just use 'W' APIs directly. We don't support Win 9x/ME any more. See bug 359808. I'll try to land the patch there today or tomorrow once I set up my machine back up.
Where SUS is supported, we can use nl_langinfo. http://www.opengroup.org/onlinepubs/009695399/basedefs/langinfo.h.html
(In reply to comment #8) > Please, just use 'W' APIs directly. We don't support Win 9x/ME any more. > See bug 359808. I'll try to land the patch there today or tomorrow once I > set up my machine back up. > Ok, I'll remove in new patch after next comments :) (In reply to comment #9) > Where SUS is supported, we can use nl_langinfo. > http://www.opengroup.org/onlinepubs/009695399/basedefs/langinfo.h.html > Can you give me more information about SUS and mozilla?
Don't forget to document how to interpret the return value of GetLocaleInfo(FIRST_DAY_OF_WEEK). Apparently Windows uses 0=Monday, 6=Sunday, while nl_langinfo uses 1=Sunday, 7=Saturday.
QA Contact: mmx_bugzilla → i18n
Attachment #253647 - Flags: review?(smontagu) → review-
Comment on attachment 253647 [details] [diff] [review] patch r- per comments 9 and 10
I don't think I would have time in nearest future to get back to this patch. So reassign to default assignee for now.
Assignee: surkov.alexander → smontagu
Status: ASSIGNED → NEW
Blocks: 521718
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: