<DataMember(Name:="responseStatus")> Public ResponseStatus As HttpStatusCode
End Class
- Public Function Translate(ByVal isHtml As Boolean, ByVal source As String, ByRef destination As String) As Boolean
+ Public Function Translate(ByVal srclng As String, ByVal dstlng As String, ByVal source As String, ByRef destination As String) As Boolean
Dim http As New HttpVarious()
Dim apiurl As String = TranslateEndPoint
Dim headers As New Dictionary(Of String, String)
headers.Add("v", "1.0")
- headers.Add("hl", "ja") ' TODO:現在のcultureを反映させる
- headers.Add("langpair", "|ja") ' TODO:現在のcultureを反映させる
- headers.Add("format", "html")
- headers.Add("q", HttpUtility.UrlPathEncode(source))
+ If String.IsNullOrEmpty(srclng) OrElse String.IsNullOrEmpty(dstlng) Then
+ Return False
+ End If
+ headers.Add("User-Agent", "Tween/" + fileVersion)
+ headers.Add("langpair", srclng + "|" + dstlng)
+
+ headers.Add("q", source)
Dim content As String = ""
If http.GetData(apiurl, headers, content) Then
Dim serializer As New DataContractJsonSerializer(GetType(TranslateResponse))
Dim res As TranslateResponse = CreateDataFromJson(Of TranslateResponse)(content)
+
+ If res.ResponseData Is Nothing Then
+ Return False
+ End If
Dim _body As String = res.ResponseData.TranslatedText
Dim buf As String = HttpUtility.UrlDecode(_body)
Dim http As New HttpVarious()
Dim apiurl As String = LanguageDetectEndPoint
Dim headers As New Dictionary(Of String, String)
+ headers.Add("User-Agent", "Tween/" + fileVersion)
headers.Add("v", "1.0")
- headers.Add("q", HttpUtility.UrlPathEncode(source))
+ headers.Add("q", source)
Dim content As String = ""
If http.GetData(apiurl, headers, content) Then
Dim serializer As New DataContractJsonSerializer(GetType(LanguageDetectResponse))
Private _SearchTabName As String = ""
Private _IsDeleted As Boolean = False
Private _InReplyToUserId As Long = 0
+ Private _langauge As String = ""
<FlagsAttribute()> _
Private Enum Statuses
_IsDeleted = value
End Set
End Property
+
+ Public Property Language As String
+ Get
+ Return _langauge
+ End Get
+ Set(ByVal value As String)
+ _langauge = value
+ End Set
+ End Property
+
Public Property FavoritedCount As Integer
Public Function Copy() As PostClass
Dim g As New Google
Dim buf As String = ""
If Not Me.ExistCurrentPost Then Exit Sub
- Dim lng As String = g.LanguageDetect(_curPost.Data)
- If lng <> "ja" AndAlso g.Translate(True, PostBrowser.DocumentText, buf) Then
- PostBrowser.DocumentText = buf
+ Dim srclng As String = g.LanguageDetect(_curPost.Data)
+ If srclng <> "ja" AndAlso g.Translate(srclng, "ja", _curPost.Data, buf) Then
+ PostBrowser.DocumentText = createDetailHtml(buf)
End If
End Sub
post.Nickname = user.Name
post.ImageUrl = user.ProfileImageUrl
post.IsProtect = user.Protected
+ post.Language = user.Lang
'Retweetした人
post.RetweetedBy = status.User.ScreenName
post.Nickname = user.Name
post.ImageUrl = user.ProfileImageUrl
post.IsProtect = user.Protected
+ post.Language = user.Lang
post.IsMe = post.Name.ToLower.Equals(_uid)
If post.IsMe Then _UserIdNo = post.UserId.ToString
End If
post.IsRead = read
post.IsReply = post.ReplyToList.Contains(_uid)
post.IsExcludeReply = False
+ post.Language = xentryNode.Item("twitter:lang").InnerText
post.IsOwl = False
If post.IsMe AndAlso Not read AndAlso _readOwnPost Then post.IsRead = True
post.Nickname = user.Name
post.ImageUrl = user.ProfileImageUrl
post.IsProtect = user.Protected
+ post.Language = user.Lang
Catch ex As Exception
TraceOut(content)
MessageBox.Show("Parse Error(CreateDirectMessagesFromJson)")
post.Nickname = user.Name
post.ImageUrl = user.ProfileImageUrl
post.IsProtect = user.Protected
+ post.Language = user.Lang
'Retweetした人
post.RetweetedBy = status.User.ScreenName
post.Nickname = user.Name
post.ImageUrl = user.ProfileImageUrl
post.IsProtect = user.Protected
+ post.Language = user.Lang
post.IsMe = post.Name.ToLower.Equals(_uid)
If post.IsMe Then _UserIdNo = post.UserId.ToString
End If
If Text Is Nothing Then Return Nothing
Dim retStr As String = Text.Replace(">", "<<<<<tweenだいなり>>>>>").Replace("<", "<<<<<tweenしょうなり>>>>>")
'uriの正規表現
- 'Const rgUrl As String = "(?<before>(?:[^\""':!=]|^|\:))" + _
- ' "(?<url>(?<protocol>https?://|www\.)" + _
- ' "(?<domain>(?:[\.-]|[^\p{P}\s])+\.[a-z]{2,}(?::[0-9]+)?)" + _
- ' "(?<path>/[a-z0-9!*'();:&=+$/%#\[\]\-_.,~@^]*[a-z0-9)=#/]?)?" + _
- ' "(?<query>\?[a-z0-9!*'();:&=+$/%#\[\]\-_.,~]*[a-z0-9_&=#])?)"
Const url_valid_general_path_chars As String = "[a-z0-9!*';:=+$/%#\[\]\-_,~]"
Const url_valid_url_path_ending_chars As String = "[a-z0-9=#/]"
Const pth As String = "(?<path>/(?:(?:\(" + url_valid_general_path_chars + "+\))" +
End Function),
RegexOptions.IgnoreCase)
- 'Dim mhs As MatchCollection = Regex.Matches(retStr, "(^|[^a-zA-Z0-9/&])[##]([0-9a-zA-Z_]*[a-zA-Z_]+[a-zA-Z_\xc0-\xd6\xd8-\xf6\xf8-\xff]*)")
- 'For Each mt As Match In mhs
- ' If Not IsNumeric(mt.Result("$2")) Then
- ' 'retStr = retStr.Replace(mt.Result("$1") + mt.Result("$2"), "<a href=""" + _protocol + "twitter.com/search?q=%23" + mt.Result("$2") + """>#" + mt.Result("$2") + "</a>")
- ' SyncLock LockObj
- ' _hashList.Add("#" + mt.Result("$2"))
- ' End SyncLock
- ' End If
- 'Next
- 'retStr = Regex.Replace(retStr, "(^|[^a-zA-Z0-9/&])([##])([0-9a-zA-Z_]*[a-zA-Z_]+[a-zA-Z0-9_\xc0-\xd6\xd8-\xf6\xf8-\xff]*)", "$1<a href=""" & _protocol & "twitter.com/search?q=%23$3"">$2$3</a>")
retStr = Regex.Replace(retStr, "(^|[^a-zA-Z0-9_/&##@@>=.])(sm|nm)([0-9]{1,10})", "$1<a href=""http://www.nicovideo.jp/watch/$2$3"">$2$3</a>")