Translating leader notes on idw using i-logic

Translating leader notes on idw using i-logic

didin.suryadi6JREK
Advocate Advocate
409 Views
2 Replies
Message 1 of 3

Translating leader notes on idw using i-logic

didin.suryadi6JREK
Advocate
Advocate

Hi

 

I am converting the drawing which has so many notes in other languages such as Spanish etc.

Can we make an i-logic to replace all notes with defined text from any language using i-logic?

 

RGds

 

DidinSpanish notes to be english by i-logic.JPG

0 Likes
410 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor

For static text is it very easy, but you need to specify languages from and to.

But this approach is very vulnerable. When somebody change anything in the text, this method can't translate it.

Better approach is to use some "textId" stored in LeaderNote attributes. Then user can specify this textId (select from list of corresponding texts) and then you store this id to attributes. When you start translation, you just read this textId and from target dictionary select appropriate text.

 

Sub Main
	Dim drawing As DrawingDocument = ThisDoc.Document
	Dim activeSheet As Sheet = drawing.ActiveSheet
	For Each oLeaderNote As LeaderNote In activeSheet.DrawingNotes.LeaderNotes
		Dim oldText = oLeaderNote.FormattedText
		Dim newText = Translate(oldText, "en", "es")
		If newText IsNot Nothing Then
			oLeaderNote.FormattedText = newText
		End If
	Next
End Sub

Dim enDictionary As New List(Of String)({
"EN description"
})


Dim esDictionary As New List(Of String)({
"ES descripción"
})


Dim deDictionary As New List(Of String)({
"DE Beschreibung"
})

Function Translate(oldText As String, fromLang As String, toLang As String) As String
	Dim fromDictionary = GetDictionary(fromLang)
	Dim toDictionary = GetDictionary(toLang)
	Dim i = fromDictionary.IndexOf(oldText)
	If i >= 0 Then
		Return toDictionary(i)
	Else
		Return Nothing
	End If
End Function

Function GetDictionary(lang As String) As List(Of String)
	Select Case lang
		Case "en"
			Return enDictionary
		Case "es"
			Return esDictionary
		Case "de"
			Return deDictionary
		Case Else
			Return Nothing
	End Select
End Function

 

0 Likes
Message 3 of 3

didin.suryadi6JREK
Advocate
Advocate

Hi Michael

 

Thanks, can you please give some example to put on the i-logic below

- from Spanish to the Indonesian language

- old text: COMO SE MESTRA

- new text: SEPERTI PETUNJUK

 

Appreciated your help and advise

0 Likes