Hi Juergen, Alle 08:19, giovedì 19 luglio 2007, Juergen Schmidt ha scritto: > Hi Paolo, > > it's a good question and i assume that you can't get a list of all > supported languages via API. For the NetBeans plugin we hard coded this > list which is of course not optimal. Anyway a list which you get from > your current working office can be out dated s well.
Grepping in the $OFFICE/program/resource/ dir, I've found that the svx*.res file contains the list that I'm looking for. I've tried to extract the strings from there with a "brute force" method :-) but without success: --------------------8<-------------------- REM ***** BASIC ***** Global oResSrv sub ExtractResStrings oResSrv = GetDefaultContext.getByName( _ "/singletons/com.sun.star.resource.OfficeResourceLoader") oBundle = oResSrv.loadBundle_default("svx") j = 0 oDoc = StarDesktop.LoadComponentFromURL( _ "private:factory/scalc","_default",0,Array()) oSheet = oDoc.Sheets(0) For I = 0 To 35000 sText = oBundle.getDirectElement("string:" & I) If Trim(sText) <> "" Then oSheet.getCellByPosition(0,j).String = "string:" & I oSheet.getCellByPosition(1,j).String = sText j = j+1 End If Next I end sub --------------------8<-------------------- Anyway I recognize that even if I would be able to extract the information from the office resources, it would be a poor solution, because it would depends from an implementation detail (the resource identifiers) that, as stated in the IDL documentation, may change in a next ooo version > I would suggest a > hard coded list + free edit field to support future languages. The list > can be updated from version to version. Yes this would be the best option, but 150 locales x 150 translations are a table with over 20K elements. It seems a huge work for a single (lazy) person (me) :-) So I'm trying find a shortcut to avoid all this hard work :-) > I will try to find out if we can provide an API for that and if the info > is available somewhere in the office (i expect not, at least not for a > single language version) I guess that the "lang-table" should be already in the office resources because it is shown in the basic IDE (the new dialog localization tool, for example) Perhaps an API that provide the information could be done "simply" creating an optional interface for the service com.sun.star.i18n.LocaleData, just like the XLocaleData2, that provides the getAllCurrencies2 method to get all currencies for a given locale. However, I think that an API for getting localized lang-Info would be a great help for developers that want to provide extensions for the basic IDE (just like basicaddonbuilder in effect) For example, extensions that assist the user in the creation of certain dialogs could use this API. Back to my specific needs: In meantime I've better investigated the API and I've found a way to get something very near to my needs. the com.sun.star.i18n.LocaleData service supports the method: XLocaleData.getAllInstalledLocaleNames() this method gets a sequence with all supported locales (currently are 149) The same interface supports also the method: XLocaleData.getLanguageCountryInfo(aLocale) Combining these two methods I've been able to get a list of all supported languages and countries with their descriptive names. Of course, descriptive names are given in English only (not localized) , but it's indeed a great step ahead for me and I will adopt this solution in my app (BasicAddonBuilder), at least in a first moment. Thank you Paolo mantovani P.S.: Just in case someone's interested, below the code that I've used to test the service. The macro creates a calc document with information about all supported locales: REM ***** BASIC ***** Sub Main oLocaleData = _ createUnoService("com.sun.star.i18n.LocaleData") oDoc = StarDesktop.LoadComponentFromURL( _ "private:factory/scalc","_default",0,Array()) oSheet = oDoc.Sheets(0) i=0 oSheet.getCellByPosition(0,i).String = "[Locale ID]" oSheet.getCellByPosition(1,i).String = "[Locale description]" i=1 For Each aLocale In oLocaleData.AllInstalledLocaleNames() aInfo = oLocaleData.getLanguageCountryInfo(aLocale) sLocID = aInfo.Language If aInfo.Country <> "" Then sLocID = sLocID & "_" & aInfo.Country End If If aInfo.Variant <> "" Then sLocID = sLocID & "_" & aInfo.Variant End If sLocDesc = aInfo.LanguageDefaultName If aInfo.CountryDefaultName <> "" Then sLocDesc = sLocDesc & " (" & aInfo.CountryDefaultName & ")" End If oSheet.getCellByPosition(0,i).String = sLocID oSheet.getCellByPosition(1,i).String = sLocDesc i = i + 1 Next End Sub --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]