Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
MODULE LANGUAGE PACK (CHARGEMENT , CREATION, TRADUCTION)
Information sur la source
Description
Ci joint un module pour créer et gérer les languages dans son appli !!! Je joint un zip pour exemple d'utilisation mais cela reste trés simple !! Aprés avoir creé l'appli , il suffit de lancer cette commande : EcritLng LaForm, chemin du fichier ex : EcritLng Me, App.Path & "/French.lng" A faire pour chaque form !!! ça créer un fichier "ini" avec extention "Lng" et pour chaque Section la propriétée Name de la form concerné, dans cette section il y a la propriétée name des controles avec le texte a afficher!!! Ensuite pour charger le language de la form par exemple : (Dans le load de la form) ChargeLng Form1, App.Path & "/French.lng" Il y aussi un fonction pour traduire le fichier directement depuis le soft, mais ça revient au mm que de traduire le fichier lng de base du Français vers l'anglais par exemple. Pour l'utiliser : TraduireLng Form1, App.Path & "/Anglais.lng" Ca ouvre pour chaque controle une inputbox qui demande le texte a ecrire dans le fichier lng... Voila c'est tous simple et ça me fait gagner pas mal de temps!!!! Donc je la post ici afin peu étre, de vous en faire gagner aussi!!!!
Source
- Dim Controle As Control
- Dim TypeCtrl As String
-
- Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
- Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
-
- Public Const SW_HIDE = 0
- Public Const GW_OWNER = 4
-
- Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
-
- Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
-
-
- Function LireINI(Entete As String, Variable As String, Fichier As String) As String
- Dim Retour As String
- Retour = String(255, Chr(0))
- LireINI = Left$(Retour, GetPrivateProfileString(Entete, ByVal Variable, "", Retour, Len(Retour), Fichier))
- End Function
-
- Function EcrireINI(Entete As String, Variable As String, Valeur As String, Fichier As String) As String
- WriteINI = WritePrivateProfileString(Entete, Variable, Valeur, Fichier)
- End Function
-
- Public Function EcritLng(Feuille As Form, Strpath As String)
- EcrireINI Feuille.Name, Feuille.Name, Feuille.Caption, Strpath
-
- For Each Controle In Feuille.Controls
- TypeCtrl = TypeName(Controle)
-
- Select Case TypeCtrl
-
- Case "Label"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
-
- Case "TextBox"
- EcrireINI Feuille.Name, Controle.Name, Controle.Text, Strpath
-
- Case "CommandButton"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
-
- Case "CheckBox"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
-
- Case "OptionButton"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
-
- Case "Menu"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
-
- Case "Frame"
- EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
- End Select
-
- Next
-
-
- End Function
-
- Public Function ChargeLng(Feuille As Form, Strpath As String)
- Feuille.Caption = LireINI(Feuille.Name, Feuille.Name, Strpath)
- For Each Controle In Feuille.Controls
- TypeCtrl = TypeName(Controle)
-
- Select Case TypeCtrl
- Case "Label"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "TextBox"
- Controle.Text = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "CommandButton"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "CheckBox"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "OptionButton"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "Menu"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
-
- Case "Frame"
- Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
- End Select
- Next
- End Function
-
- Public Function TraduireLng(Feuille As Form, Strpath As String)
-
- Dim Tmp As String
- Tmp = InputBox("Caption de : " & Feuille.Caption)
- EcrireINI Feuille.Name, Feuille.Name, Tmp, Strpath
-
- For Each Controle In Feuille.Controls
- TypeCtrl = TypeName(Controle)
-
- Select Case TypeCtrl
-
- Case "Label"
- Tmp = InputBox("Caption de : " & Controle.Caption, "Label")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "TextBox"
- Tmp = InputBox("Text de : " & Controle.Text, "TextBox")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "CommandButton"
- Tmp = InputBox("Caption de : " & Controle.Caption, "Bouton de commande")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "CheckBox"
- Tmp = InputBox("Caption de : " & Controle.Caption, "CheckBox")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "OptionButton"
- Tmp = InputBox("Caption de : " & Controle.Caption, "Bouton d'option")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "Menu"
- Tmp = InputBox("Texte de : " & Controle.Caption, "Menu")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- Case "Frame"
- Tmp = InputBox("Texte de : " & Controle.Caption, "Frame")
- EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
-
- End Select
-
- Next
- End Function
Dim Controle As Control
Dim TypeCtrl As String
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const GW_OWNER = 4
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Function LireINI(Entete As String, Variable As String, Fichier As String) As String
Dim Retour As String
Retour = String(255, Chr(0))
LireINI = Left$(Retour, GetPrivateProfileString(Entete, ByVal Variable, "", Retour, Len(Retour), Fichier))
End Function
Function EcrireINI(Entete As String, Variable As String, Valeur As String, Fichier As String) As String
WriteINI = WritePrivateProfileString(Entete, Variable, Valeur, Fichier)
End Function
Public Function EcritLng(Feuille As Form, Strpath As String)
EcrireINI Feuille.Name, Feuille.Name, Feuille.Caption, Strpath
For Each Controle In Feuille.Controls
TypeCtrl = TypeName(Controle)
Select Case TypeCtrl
Case "Label"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
Case "TextBox"
EcrireINI Feuille.Name, Controle.Name, Controle.Text, Strpath
Case "CommandButton"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
Case "CheckBox"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
Case "OptionButton"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
Case "Menu"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
Case "Frame"
EcrireINI Feuille.Name, Controle.Name, Controle.Caption, Strpath
End Select
Next
End Function
Public Function ChargeLng(Feuille As Form, Strpath As String)
Feuille.Caption = LireINI(Feuille.Name, Feuille.Name, Strpath)
For Each Controle In Feuille.Controls
TypeCtrl = TypeName(Controle)
Select Case TypeCtrl
Case "Label"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "TextBox"
Controle.Text = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "CommandButton"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "CheckBox"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "OptionButton"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "Menu"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
Case "Frame"
Controle.Caption = LireINI(Feuille.Name, Controle.Name, Strpath)
End Select
Next
End Function
Public Function TraduireLng(Feuille As Form, Strpath As String)
Dim Tmp As String
Tmp = InputBox("Caption de : " & Feuille.Caption)
EcrireINI Feuille.Name, Feuille.Name, Tmp, Strpath
For Each Controle In Feuille.Controls
TypeCtrl = TypeName(Controle)
Select Case TypeCtrl
Case "Label"
Tmp = InputBox("Caption de : " & Controle.Caption, "Label")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "TextBox"
Tmp = InputBox("Text de : " & Controle.Text, "TextBox")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "CommandButton"
Tmp = InputBox("Caption de : " & Controle.Caption, "Bouton de commande")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "CheckBox"
Tmp = InputBox("Caption de : " & Controle.Caption, "CheckBox")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "OptionButton"
Tmp = InputBox("Caption de : " & Controle.Caption, "Bouton d'option")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "Menu"
Tmp = InputBox("Texte de : " & Controle.Caption, "Menu")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
Case "Frame"
Tmp = InputBox("Texte de : " & Controle.Caption, "Frame")
EcrireINI Feuille.Name, Controle.Name, Tmp, Strpath
End Select
Next
End Function
Conclusion
Ps : Pas de capture d'écran : ça sert a rien tous est expliqué en commentaire!!! mais je joint la Src avec un Exemple d'utilisation.
Je n'ai pas gérer le contenu des listbox car dans mon soft je charge des données d'un fichier externe , mais il est facile de rajouter le code afin de les gérer!!!
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Sources de la même categorie
Commentaires
|
CalendriCode
| | | L | M | M | J | V | S | D |
| | 1 | 2 | 3 | 4 | 5 | 6 |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | | | |
|
|