for a selection list in a GUI dialogue, I need to figure out the following three things:
1. All languages known to OpenOffice (i.e. all installed locales).
2. All languages, for which a spell checker is available.
3. All languages used in the current document.
For these three problems I found the following three solutions:
Code: Select all
' All languages known to OpenOffice (i.e. all installed locales)
aLocales = createUnoService("com.sun.star.i18n.LocaleData").getAllInstalledLocaleNames()
' All languages, for which a spell checker is available
aLocales = createUnoService("com.sun.star.linguistic2.LinguServiceManager").SpellChecker.Locales
' All languages used in the current document
aLocales = ThisComponent.getDocumentLanguages(1,999) '1: only return Western languages, 999: an arbitrarily chosen maxCount parameter
Code: Select all
Language specifies an ISO Language Code.
Country specifies an ISO Country Code.
Variant contains a variant of the locale; codes are vendor and browser-specific.
Code: Select all
createUnoService("com.sun.star.i18n.LocaleData").getLanguageCountryInfo(aLocales(i))
Code: Select all
Language ISO-639 language code, for example, "en" or "de"
LanguageDefaultName Descriptive language name, for example, "English" or "German"
Country ISO-3166 country code, for example, "US" or "DE"
CountryDefaultName Descriptive country name, for example, "United States" or "Germany"
Variant A variant name
However, it returns localised names, i.e. instead of 'English (United States)' or 'German (Germany)' I get something like 'Englisch (USA)' and 'Deutsch (Deutschland)'. While this is actually preferable for the GUI, I need to convert the display name back to ISO codes once the user has made their selection, and the only solution I have come up with so far is to iterate through all available locales, generate the display name and compare it to the selection, which will obviously fail if the compared display names are in different languages.
So here are the questions: Is there a way to tailor the function to obey the GUI's locale settings and return localised names, or is there an alternative way to convert locales to localised display names, or is there an alternative way to find all the languages used in the current document?
Thanks, and best regards,
ah8