[Gambas-user] Translations

Martin mbelmonte at belmotek.net
Tue Jan 17 10:15:13 CET 2023


El 17/1/23 a las 9:48, gian via User escribió:
> this morning with a cool mind, rereading what you wrote, I understand 
> the point and yes; it is for the reason you described that if you check 
> the CheckBoxes in the window the dashes disappear.
> 
> Perhaps it would be more correct if they stayed?

Right.
I think the "problem" lies in the fact that the import algorithm ignores 
the ignore flag (a funny phrase) :-)
Look, here is the import code, if I understand correctly it does not 
take into account the flag "# gb-ignore".

Private Sub ImportMessage(sPath As String, bReplace As Boolean) As Integer

   Dim hFic As File
   Dim sLine As String
   Dim sMsgComment As String
   Dim bFuzzy As Boolean
   Dim sMsgId As String
   Dim iMode As Integer
   Dim sMsgStr As String
   Dim iIndex As Integer
   Dim nTrans As Integer
   Dim sCharset As String

   ' sTemp = Temp$()
   ' sOutput = Temp$()
   ' Shell "msgconv -t UTF-8 -o " & Quote.Shell(sTemp) & " " & 
Quote.Shell(sPath) & " > " & Quote.Shell(sOutput) & " 2>&1" Wait
   ' If Process.LastValue Then
   '   $sErrMerge = "\n\n" & DConv(File.Load(sOutput))
   '   Error.Raise(("Unable to convert translation file to UTF-8."))
   ' Endif

   InitIndex

   hFic = Open sPath

   Do

     If Not Eof(hFic) Then

       Line Input #hFic, sLine

       If Left$(sLine) = "#" Then

         If Left$(sLine, 2) = "#:" Then
           sMsgComment = Trim(Mid$(sLine, 3))
           Continue
         Endif

         If Left$(sLine, 2) = "#," Then
           If InStr(sLine, "fuzzy") Then
             bFuzzy = True
             Continue
           Endif
         Endif

         Continue

       Endif

       If Left$(sLine, 6) = "msgid " Then
         sMsgId = Mid$(sLine, 8, -1)
         iMode = MODE_MSGID
         Continue
       Endif

       If Left$(sLine, 7) = "msgstr " Then
         sMsgStr = Mid$(sLine, 9, -1)
         iMode = MODE_MSGSTR
         Continue
       Endif

       If Left$(sLine) = Chr$(34) Then
         If iMode = MODE_MSGID Then
           sMsgId = sMsgId & Mid$(sLine, 2, -1)
         Else If iMode = MODE_MSGSTR Then
           If Not sMsgId Then
             If sLine Like "\"Content-type:*; charset=*" Then
               sLine = Replace(Mid$(sLine, 2, -1), "\\n", "")
               Try sCharset = UCase(Trim(Scan(sLine, "*; charset=*")[1]))
               If sCharset = "UTF-8" Then sCharset = ""
             Endif
           Else
             sMsgStr = sMsgStr & Mid$(sLine, 2, -1)
           Endif
         Endif
         Continue
       Endif

     Endif

     If Trim(sMsgId) Then

       If sCharset Then sMsgStr = Conv(sMsgStr, sCharset, "UTF-8")

       iIndex = FindIndex(sMsgId)
       If iIndex <= 0 Then
         sMsgId = CControl.RemoveShortcut(sMsgId)
         sMsgStr = CControl.RemoveShortcut(sMsgStr)
         iIndex = FindIndex(sMsgId)
       Endif

       If iIndex > 0 Then
         If bReplace Or If cvwTranslate[iIndex][1] = "" Then

           If sMsgStr = "-\\n" Then sMsgStr = "-"

           If bFuzzy Then
             bFuzzy = False
           Else
             cvwTranslate[iIndex][1] = sMsgStr
             If sMsgStr Then
               Inc $nTrans
               Inc nTrans
             Endif
           Endif

         Endif

       Endif

     Endif

     sMsgId = ""
     sMsgComment = ""
     sMsgStr = ""
     bFuzzy = False

     If Eof(hFic) Then Break

   Loop

   Close hFic

   Return nTrans

End

Best regards
Martin.


More information about the User mailing list