Maybe not the best way, but one way that doesn't require a lot of Selects
There are ways to embed the strings into the CustomXML for a document if you want to get sophisticated
Option Explicit
Public Enum eLang
langEng = 0
langGer = 2
langSpa = 3
' etc.
langRus = 12
End Enum
Public Enum eText
txtYes = 0
txtNo = 1
txtMaybe = 2
' etc.
txtAllDone = 29
End Enum
Public langInUse As eLang
Public aryText(langEng To langRus) As Variant
Sub Init()
aryText(langEng) = Split("Yes;No;Maybe", ";")
aryText(langGer) = Split("Ya;Nein;Vielleicht", ";")
aryText(langSpa) = Split("Si;Prohibido;Tal vez", ";")
langInUse = langEng
MsgBox aryText(langInUse)(txtYes)
MsgBox aryText(langInUse)(txtNo)
MsgBox aryText(langInUse)(txtMaybe)
langInUse = langGer
MsgBox aryText(langInUse)(txtYes)
MsgBox aryText(langInUse)(txtNo)
MsgBox aryText(langInUse)(txtMaybe)
langInUse = langSpa
MsgBox aryText(langInUse)(txtYes)
MsgBox aryText(langInUse)(txtNo)
MsgBox aryText(langInUse)(txtMaybe)
End Sub
It should be possible to automatically set langInUse. This returns ENU for English-US
Option Explicit
Private Declare PtrSafe Function GetLocaleInfoEx Lib "kernel32" (ByVal lpLocaleName As LongPtr, ByVal LCType As Long, ByVal lpLCData As LongPtr, ByVal cchData As Long) As Long
Const LOCALE_SABBREVLANGNAME As Long = &H3
'Abbreviated name of the language. In most cases, the name is created by taking the
'two-letter language abbreviation from ISO Standard 639 and adding a third letter, as appropriate,
'to indicate the sublanguage. For example, the abbreviated name for the language corresponding
'to the English (United States) locale is ENU.
'ref: https://en.wikipedia.org/wiki/List_of_ISO_639-3_codes
Function LocalLanguage() As String
Dim sLocaleName As String
Dim sRetBuffer As String
Dim nCharsRet As Long
nCharsRet = GetLocaleInfoEx(0, LOCALE_SABBREVLANGNAME, StrPtr(sRetBuffer), 0)
If nCharsRet > 0 Then
sRetBuffer = String(nCharsRet, Chr$(0))
nCharsRet = GetLocaleInfoEx(0, LOCALE_SABBREVLANGNAME, StrPtr(sRetBuffer), nCharsRet)
LocalLanguage = Left(sRetBuffer, Len(sRetBuffer) - 1)
End If
End Function
'you might get by with just the first 2 letters to get into the right family
Sub test()
MsgBox LocalLanguage
End Sub