Top > OOoBasic > Dialog > LanguageList

言語リスト Edit

利用可能な言語のリストを取得します。

利用できる言語の一覧は com.sun.star.i18n.LocaleData サービスから取得できます。

Type aCategorizedLocales
 aWesternLocales As Object
 aAsianLocales As Object
 aCTLLocales As Object
End Type


Function GetLocaleData() As aCategorizedLocales
 oLocaleData = CreateUnoService("com.sun.star.i18n.LocaleData")
 aLocales = oLocaleData.getAllInstalledLocaleNames()
 
 nWestern = 0
 nAsian = 0
 nCTL = 0
 
 Dim aWesternLocales(130) As New com.sun.star.i18n.LanguageCountryInfo
 Dim aAsianLocales(6) As New com.sun.star.i18n.LanguageCountryInfo
 Dim aCTLLocales(20) As New com.sun.star.i18n.LanguageCountryInfo
 
 sLang = ""
 For i = 0 To UBound(aLocales) step 1
   oInfo = oLocaleData.getLanguageCountryInfo(aLocales(i))
   sLang = aLocales(i).Language
   
   If sLang = "zh" OR sLang = "ja" OR sLang = "ko" Then
     If nAsian > 6 Then
       ReDim Preserve aAsianLocales(nAsian)
     End If
     aAsianLocales(nAsian) = oInfo
     nAsian = nAsian + 1
   ElseIf sLang = "am" OR sLang = "as" OR sLang = "bn" OR sLang = "my" OR _
          sLang = "" OR sLang = "he" OR sLang = "yi" OR sLang = "mr" OR _
          sLang = "pa" OR sLang = "gu" OR sLang = "hi" OR sLang = "kn" OR _
          sLang = "ks" OR sLang = "km" OR sLang = "lo" OR sLang = "ml" OR _
          sLang = "" OR sLang = "mn" OR sLang = "ne" OR sLang = "or" OR _
          sLang = "sa" OR sLang = "sd" OR sLang = "si" OR sLang = "" OR _
          sLang = "ta" OR sLang = "te" OR sLang = "th" OR sLang = "bo" OR _
          sLang = "dz" OR sLang = "ur" OR sLang = "ku" OR sLang = "" OR _
          sLang = "" OR sLang = "" OR sLang = "mai" OR sLang = "ug" Then
     If nCTL > 20 Then
       ReDim Preserve aCTLLocales(nCTL)
     End If
     aCTLLocales(nCTL) = oInfo
     nCTL = nCTL + 1
  Else
     If nWestern > 130 Then
       ReDim Preserve aWesternLocales(nWestern)
     End If
     aWesternLocales(nWestern) = oInfo
     nWestern = nWestern + 1
   End If
 Next
 
 aLocales = CreateUnoObject("aCategorizedLocales")
 aLocales.aWesternLocales = SortLanguageCountryInfo(aAsianLocales)
 aLocales.aAsianLocales = SortLanguageCountryInfo(aWesternLocales)
 aLocales.aAsianLocales = SortLanguageCountryInfo(aCTLLocales)
 GetLocaleData = aLocales
End Function

Function SortLanguageCountryInfo(aData As Object) As Object

 Dim aSortData(UBound(aData)) 'As aKeySort
 For i = 0 To UBound(aSortData) step 1
   aSortData(i) = Array(aData(i).LanguageDefaultName, aData(i))
 Next
 
 keyqsort(aSortData, 0, UBound(aSortData))
 
 Dim aSorted(UBound(aSortData)) As New com.sun.star.i18n.LanguageCountryInfo
 For i = 0 To UBound(aSortData) step 1
   aSorted(i) = aSortData(i)(1)
 Next
 SortLanguageCountryInfo = aSorted

End Function


Function keyqsort( a, i, j )
 If NOT ( i = j ) AND ( i >= 0 AND j >= 0 ) Then
   p = keypivot( a, i, j )
   If ( p <> -1 ) Then
     k = keypartition( a, i, j, a(p) )
     keyqsort( a, i, k -1 )
     keyqsort( a, k, j )
   End If
 End If
End Function

Function keypartition( a, i, j, x )
 l = i
 r = j
 y = x
 v = y(0)
 Do While ( l <= r )
   Do While ( l <= j ) AND ( StrComp( a(l)(0), v ) = -1 )'a(l) < y )
     l = l + 1
   Loop
   s = a(r)(0)
   'v = y.sKey
   Do While ( r >= i ) AND ( StrComp( a(r)(0), v ) >= 0 )'a(r) >= y )
   'Do While ( r >= i ) AND ( StrComp( s, v ) >= 0 )'a(r) >= y )
     r = r - 1
     's = a(r).sKey
     'v = y.sKey
   Loop
   
   If ( l > r ) Then Exit Do
   t = a(l)
   a(l) = a(r)
   a(r) = t
   
   l = l + 1
   r = r - 1
 Loop
 keypartition = l
End Function

Function keypivot( a, i, j )
 k = i + 1
 Do while ( k <= j ) AND ( StrComp( a(i)(0), a(k)(0) ) = 0 )'a(i) = a(k) )
   k = k + 1
   If k > j Then Exit Do
 Loop
 If ( k > j ) Then
   k = -1
 Else
   If ( StrComp( a(i)(0), a(k)(0) ) >= 0 ) Then'a(i) >= a(k) ) Then
     k = i
   End If
 End If
 keypivot = k
End Function

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes