2012-05-29 20:56:16 +03:00
' Output a file
' If there is no translation then we output the line as a comment
' that starts with #EN# indicating that translation is required
Sub Export_File(sType, iCol As Integer)
Dim oFile As Integer
Dim iRow As Integer
Dim iBlankLines As Integer
Dim sLangCode As String
Dim sOut As String
Dim sTemp As String
Dim bOut() As Byte
Dim shSheet As Worksheet: Set shSheet = Worksheets(sType)
2012-05-29 20:59:21 +03:00
sFilename = sType & "_" & LCase$(shSheet.Cells(cLanguageCodeRow, iCol).Value) & ".json"
2012-05-29 20:56:16 +03:00
oFile = FreeFile()
sFullPath = Application.ActiveWorkbook.Path & "\" & sFilename
On Error Resume Next
Kill sFullPath
Open sFullPath For Output As #oFile
Close #oFile
On Error GoTo 0
Open sFullPath For Binary Access Write As #oFile
' Output comment on version as first line
2012-05-29 20:59:21 +03:00
sOut = "{" & vbCrLf
2012-05-29 20:56:16 +03:00
bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
Put #oFile, , bOut
iRow = cFirstDataRow
Do
sTemp = shSheet.Cells(iRow, cKeywordCol).Value
2012-05-29 20:59:21 +03:00
sOut = "// " & sTemp
2012-05-29 20:56:16 +03:00
' Print #oFile, sTemp;
If Len(sTemp) = 0 Then
iBlankLines = iBlankLines + 1
Else
iBlankLines = 0
2012-11-30 10:06:07 +02:00
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
2012-05-29 20:59:21 +03:00
sOut = """" & sTemp & """" & ":"
2012-05-29 20:56:16 +03:00
' Print #oFile, "=";
sTemp = shSheet.Cells(iRow, iCol).Value
If Len(sTemp) > 0 Then
2012-05-29 20:59:21 +03:00
sOut = sOut & """" & sTemp & ""","
sOut = sOut & vbCrLf
bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
Put #oFile, , bOut
2012-05-29 20:56:16 +03:00
' Print #oFile, sTemp;
Else
' If no language specific one supplied then
' output English one as a comment starting with '#EN#'
' (as long this is not the english column with empty value)
If iCol <> cEnglishLangCol Then
2012-05-29 20:59:21 +03:00
sOut = "// EN" & sOut
2012-05-29 20:56:16 +03:00
End If
sOut = sOut & shSheet.Cells(iRow, 3).Value
' Print #oFile, shSheet.Cells(iRow, 3).Value;
End If
End If
End If
' Print #oFile, "" ' Force new line
iRow = iRow + 1
Loop Until (iBlankLines > 5)
2012-05-29 20:59:21 +03:00
sOut = """fin"":""fin""" & vbCrLf & "}" & vbCrLf
bOut = UnicodeToBytes(Worksheets(cConfiguration).Cells(cOutputFormatRow, cOutputFormatCol), sOut)
Put #oFile, , bOut
2012-05-29 20:56:16 +03:00
Close #oFile
End Sub