我正在使用Bootstrap Datepicker available here,一切正常。但是,我希望在给定用户首选语言的情况下本地化日历。我在初始化datepicker时设置了以下内容:
locale: 'fr'
但是,我收到一个控制台错误,内容如下:
未捕获的TypeError:locale()语言环境fr未从当前区域设置加载!
我在项目中加入了MomentJS:
<script src="/vendors/moment/min/moment.min.js"></script>
这是我的第一次实施,所以我觉得我错过了一些简单但却无法解决的问题。
答案 0 :(得分:10)
替换
FOO
通过
/moment/min/moment.min.js
它会起作用
答案 1 :(得分:8)
正如错误消息所示,您只需要包含所需的区域设置即可解决您的问题。如果您只需要 Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
Dim X1, X2, A3 As Short
Dim A1, A2, A4 As MsgBoxResult
Dim SW As Boolean = vbFalse
ComputerName = My.Computer.Name
'Add initialization code after the call to InitializeComponent
Try
Dim webservice As New biz.palatineindustries.www.Service1
webservice = New biz.palatineindustries.www.Service1
webservice.Timeout = 60000
If My.Computer.Name.ToString.Length > 2 Then
If My.Computer.Name.ToString.Substring(0, 3).ToUpper = "FBI" Then
A1 = MsgBox("Use PRODUCTION Website?", MsgBoxStyle.YesNo)
Select Case A1
Case MsgBoxResult.Yes
webservice.Url = "http://www.auctioncharitysoftware.com/service1.asmx"
Case Else
webservice.Url = "http://www.palatineindustries.biz/service1.asmx"
End Select
A4 = MsgBox("Use computer name other than " & ComputerName & "?", MsgBoxStyle.YesNo)
Select A4
Case MsgBoxResult.Yes
Dim newFrm As New Form
Dim txtbox As New TextBox
AddHandler txtbox.TextChanged, AddressOf txb_TextChanged
newFrm.Controls.Add(txtbox)
newFrm.ShowDialog()
MsgBox(ComputerName)
End Select
Else
webservice.Url = "http://www.auctioncharitysoftware.com/service1.asmx"
End If
Else
webservice.Url = "http://www.auctioncharitysoftware.com/service1.asmx"
End If
Dim str As String = webservice.UpcomingAuctions
Dim CurrentAuctions() As String = Split(str, "|")
' MsgBox("Going to web service: A3 = webservice.TypeOfInstall(" & ComputerName & ",)")
A3 = webservice.TypeOfInstall(ComputerName, Nothing)
' MsgBox("Web returned:" & A3)
Select Case A3
Case PC.PCType.InitialMasterInstall
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialMasterInstall, String))
' MsgBox("InitialMasterInstall SET: " & PC.PCType.InitialMasterInstall)
Case PC.PCType.MasterSoftwareUpdate
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.MasterSoftwareUpdate, String))
Case PC.PCType.InitialSlaveInstall
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialSlaveInstall, String))
Case PC.PCType.SlaveSoftwareUpdate
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.SlaveSoftwareUpdate, String))
Case PC.PCType.Unknown
For X1 = 0 To CurrentAuctions.Count - 2 Step 2
A1 = MsgBox("Is this " & CurrentAuctions(X1) & "?", MsgBoxStyle.YesNo)
Select Case A1
Case MsgBoxResult.Yes
SW = vbTrue
Exit For
End Select
Next
If SW = vbFalse Then
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.Unknown, String))
Else
' MsgBox("Sending this to the web: Computername - (" & ComputerName & ") Auction Name - (" & CurrentAuctions(X1 + 1) & ")")
X2 = webservice.TypeOfInstall(ComputerName, CurrentAuctions(X1 + 1))
' MsgBox("Got this back from the web: (" & X2 & ")")
Select Case X2
Case PC.PCType.InitialMasterInstall
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialMasterInstall, String))
Case PC.PCType.MasterSoftwareUpdate
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.MasterSoftwareUpdate, String))
Case PC.PCType.InitialSlaveInstall
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialSlaveInstall, String))
Case PC.PCType.SlaveSoftwareUpdate
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.SlaveSoftwareUpdate, String))
Case PC.PCType.Unknown
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.Unknown, String))
Case Else
MsgBox("Got this back from the web, and this is an error: (" & X2 & ")")
End Select
End If
Case Else
' YIKES
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialMasterInstall, String))
End Select
Catch ex As Exception
MsgBox("2. " & ex.Message)
SaveSetting("PalatineIndustries", "Auction", "TypeOfInstallation", CType(PC.PCType.InitialMasterInstall, String))
End Try
' MsgBox(GetSetting("PalatineIndustries", "Auction", "TypeOfInstallation") & " is the type of install")
End Sub
区域设置,则可以添加以下内容:
fr
<script src="/vendors/moment/locale/fr.js"></script>
导入后。
修改强>
如果您需要多个区域设置,则可以导入moment
而不是locales.js
。此外,moment提供单个文件fr.js
,带有时刻库+所有支持的语言环境。
如果要为选择器动态设置区域设置,可以使用locale
函数:
moment-with-locales.min.js