Y a t'il une solution dans ce genre ? Quelque chose de plus simple pour des textes un peu long, genre des aides.
bonjour,
en gambas, cela est relativement simple pour internationaliser une application. Il y a des .po .mo .pot, qui se font presque automatiquement.
interface, bouton, menu, texte, notification ...
-projet/propriétés/options projet traduisible + langue anglais
--> un toolbutton "drapeau bleu" apparaît. Choisir les langues.
-installer
gettext* et
translate-shell
-outils/préferences/projets/ -> translate-shell ( si on veut une traduction automatique )
-
mettre tout ce que l'on veut traduire entre parenthèses ; cela sera détecté par le toolbutton "drapeau bleu". Compléter pour chaque traduction & vérifier & enregistrer
exemples
System.Language = "ja_JP.utf8"
'System.Language = "ar_EG.utf8"
Print ("hello")
Print ("house")
Print ("car")
Public Sub Button1_Click()
Dim tr As String
tr = ("the house is pretty")
Button1.Text = ("open")
Message(tr)
End
Public Sub Init_Demo_Menu()
Dim tmp As Menu, lg As New String[5, 3, 5], h, i, j As Short
System.Language = "ja_JP.utf8"
'horizontal
lg[0, 0, 0] = "Menu Global"
lg[0, 1, 0] = "Menu Sup."
lg[0, 2, 0] = "Options"
'Menu Global
'vertical
lg[1, 0, 0] = ("graphics")
lg[2, 0, 0] = ("utilities")
lg[3, 0, 0] = ("accessories")
lg[4, 0, 0] = ("network")
' graphiques
lg[1, 0, 1] = "gimp"
lg[1, 0, 2] = "pinta"
lg[1, 0, 3] = "dessin"
'utilitaires
lg[2, 0, 1] = "foo"
lg[2, 0, 2] = "bar"
'accessoires
lg[3, 0, 1] = "calculatrice"
'réseaux
lg[4, 0, 1] = "wireshark"
lg[4, 0, 2] = "firefox"
lg[4, 0, 3] = "chromium"
lg[4, 0, 4] = "opera"
'Menu Sup.
'vertical
lg[1, 1, 0] = "a"
lg[2, 1, 0] = "b"
lg[3, 1, 0] = "c"
lg[4, 1, 0] = "d"
' a
lg[1, 1, 1] = "aa"
lg[1, 1, 2] = "ab"
lg[1, 1, 3] = "ac"
'b
lg[2, 1, 1] = "ba"
lg[2, 1, 2] = "bb"
'c
lg[3, 1, 1] = "ca"
'd
lg[4, 1, 1] = "da"
lg[4, 1, 2] = "db"
lg[4, 1, 3] = "dc"
lg[4, 1, 4] = "dd"
'Options
'vertical
lg[1, 2, 0] = ("settings")
lg[2, 2, 0] = "test-ei"
'settings
lg[1, 2, 1] = "config"
lg[1, 2, 2] = "config_plus"
'Menu Horizontal
For h = 0 To 2
If lg[0, h, 0] Then
tmp = New Menu(FMain)
tmp.Text = lg[0, h, 0]
tmp.Name = "H" & CStr(h)
tmp.Visible = True
tmp.Tag = h
If Not ms.ExistByRef(tmp) Then ms[0, h, 0] = tmp
Endif
'Menu Vertical
For i = 1 To 4
If lg[i, h, 0] Then
tmp = New Menu(ms[0, h, 0]) As "ei"
tmp.Name = "V" & CStr(i)
tmp.Tag = i & h & 0
tmp.Text = lg[i, h, 0]
If Not ms.ExistByRef(tmp) Then ms[i, h, 0] = tmp
Endif
For j = 1 To 4
If lg[i, h, j] Then
tmp = New Menu(ms[i, h, 0]) As "ej"
tmp.Name = "M" & CStr(i) & CStr(h) & CStr(j)
tmp.Tag = i & h & j
tmp.Text = lg[i, h, j]
If Not ms.ExistByRef(tmp) Then ms[i, h, j] = tmp
Endif
Next
Next
Next
End
Public Sub ej_Click()
Dim focus As Menu
focus = Last
Message.Info(focus.text)
End
Public Sub ei_Click()
Dim focus As Menu
focus = Last
Message.Info("testa")
End
pour vérifier côté utilisateur, client, par exemple une traduction en japonais.
il faut installer les locales language-pack-ja*
et simuler avec
System.Language = "ja_JP.utf8"
:~$ ls ~/gambas/projet_foo/.lang/
ar.mo ar.po en.mo en.po FMain.pot fr.mo fr.po ja.mo ja.po #project.pot