Je ne vois pas mon message où j'avais posté le code de la macro, donc je
recommence en utilisant la boite mail cette fois (je comprends rien à ce
système de mélange forum/mailing list, première fois que je vois ça désolé).
Comme je le disais précédemment, le fichier JSON créé par la macro est
apparemment ANSI, je ne sais pas lui dire de faire de l'UTF-8. Quand je
crée au préalable un fichier en UTF-8, la macro l'écrase pour en refaire un
en ANSI.
Convertir le fichier en UTF-8 après coup n'enlève pas les "?". J'ai essayé
plusieurs éditeurs de texte et plusieurs fontes.
Le copier/coller fait un peu buguer l'indentation.
Dans mon fichier Calc, de la colonne A à D, ce sont les balises et marques
pour le formatage du langage JSON.
De la colonne E à J ce sont les langues.
La macro parse les lignes et les écrit à la suite dans un fichier .json
propre à chaque langue en créant la bonne indentation et le bon formatage
du langage.
REM ***** BASIC *****
Sub Main
Dim oFeuille as object, Cellule as object
Dim Resultat as string
oFeuille = ThisComponent.Sheets.getByName("quiz")
Nblang=6
for Lang=0 to (Nblang-1)
if Lang=0 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "en.json"
if Lang=1 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "fr.json"
if Lang=2 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "de.json"
if Lang=3 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "es.json"
if Lang=4 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "it.json"
if Lang=5 then Fichier= Left(ThisComponent.URL , Len(ThisComponent.URL)-16)
& "kr.json"
open Fichier for output as #1
for l=1 to 350 ' lignes (parse l'intégralité du document)
Resultat=""
for c=0 to 4
Cellule = oFeuille.getCellByPosition(c,l)
CelluleLang = oFeuille.getCellByPosition(c+Lang,l)
CelluleLangSuivante = oFeuille.getCellByPosition(c+Lang,l+1)
if c=0 and len(Cellule.String)>0 then
Resultat = Cellule.String
goto quiznext
endif
if c<4 and len(Cellule.String)>1 then
Resultat = Resultat & Cellule.String
endif
if c=4 and len(CelluleLang.String)>1 and
len(CelluleLangSuivante.String)>1 then Resultat = Resultat & " """ &
CelluleLang.String & ""","
if c=4 and l<>54 and len(CelluleLang.String)>1 and
len(CelluleLangSuivante.String)=0 then Resultat = Resultat & " """ &
CelluleLang.String & """"
if c=4 and l=54 then Resultat = Resultat & " """ & CelluleLang.String &
""","
if len(Cellule.String)=0 then Resultat = Resultat & " "
quiznext:
next c
if len(Resultat)>1 then
print #1, Resultat
endif
next l
close #1
next Lang