Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.8KB

  1. ' Output a file
  2. ' If there is no translation then we output the line as a comment
  3. ' that starts with #EN# indicating that translation is required
  4. Sub Export_File(sType, iCol As Integer)
  5. Dim oFile As Integer
  6. Dim iRow As Integer
  7. Dim iBlankLines As Integer
  8. Dim sLangCode As String
  9. Dim sOut As String
  10. Dim sTemp As String
  11. Dim bOut() As Byte
  12. Dim shSheet As Worksheet: Set shSheet = Worksheets(sType)
  13. sFilename = sType & "_" & LCase$(shSheet.Cells(cLanguageCodeRow, iCol).Value) & ".json"
  14. oFile = FreeFile()
  15. sFullPath = Application.ActiveWorkbook.Path & "\" & sFilename
  16. On Error Resume Next
  17. Kill sFullPath
  18. Open sFullPath For Output As #oFile
  19. Close #oFile
  20. On Error GoTo 0
  21. Open sFullPath For Binary Access Write As #oFile
  22. ' Output comment on version as first line
  23. sOut = "{" & vbCrLf
  24. bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
  25. Put #oFile, , bOut
  26. iRow = cFirstDataRow
  27. Do
  28. sTemp = shSheet.Cells(iRow, cKeywordCol).Value
  29. sOut = "// " & sTemp
  30. ' Print #oFile, sTemp;
  31. If Len(sTemp) = 0 Then
  32. iBlankLines = iBlankLines + 1
  33. Else
  34. iBlankLines = 0
  35. If Not isComment(sTemp) And (Not (sTemp Like "config*") Or sTemp Like "config.Language*") And Not sTemp Like "gui*" And Not sTemp Like "error*" And Not sTemp Like "info*" And Not sTemp Like "stats*" Then
  36. sOut = """" & sTemp & """" & ":"
  37. ' Print #oFile, "=";
  38. sTemp = shSheet.Cells(iRow, iCol).Value
  39. If Len(sTemp) > 0 Then
  40. sOut = sOut & """" & sTemp & ""","
  41. sOut = sOut & vbCrLf
  42. bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
  43. Put #oFile, , bOut
  44. ' Print #oFile, sTemp;
  45. Else
  46. ' If no language specific one supplied then
  47. ' output English one as a comment starting with '#EN#'
  48. ' (as long this is not the english column with empty value)
  49. If iCol <> cEnglishLangCol Then
  50. sOut = "// EN" & sOut
  51. End If
  52. sOut = sOut & shSheet.Cells(iRow, 3).Value
  53. ' Print #oFile, shSheet.Cells(iRow, 3).Value;
  54. End If
  55. End If
  56. End If
  57. ' Print #oFile, "" ' Force new line
  58. iRow = iRow + 1
  59. Loop Until (iBlankLines > 5)
  60. sOut = """fin"":""fin""" & vbCrLf & "}" & vbCrLf
  61. bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
  62. Put #oFile, , bOut
  63. Close #oFile
  64. End Sub