#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import importlib
def trad_FR():
lang_file = "FR"
from lang_FR import lang
print(lang["It_s_a_sentence"])
def trad_EN():
lang_file = "EN"
from lang_EN import lang
print(lang["It_s_a_sentence"])
lang_file = "EN"
lang_filename = ("lang." + lang_file)
from lang_EN import *
print("INIT lang.py: "+lang["It_s_a_sentence"])
text="It's a sentence"
et que tu souhaites le traduire (ou le faire traduire) par "C'est une phrase" en français, "Es una frase" en espagnol, "Es ist eine Phrase" en allemand, etc...text="It's a sentence"
va donc devenir: initialisation en haut de code par strTextToDisplay="It's a sentence"
puis utilisation dans Label par text=strTextToDisplay
strTextToDisplay=lang["it_s_a_sentence"]
lang={}
lang["it_s_a_sentence"]="It's a sentence"
[...]
strTextToDisplay=lang["it_s_a_sentence"]
[...]
Label(fenExplo, text=strTextToDisplay, fg="white",...
lang["Left"]="Gauche"
lang["Right"]="Droite"
lang["Up"]="Haut"
lang["Down"]="Bas"
lang["Settings"]="Paramètres"
etc...# language file
# this is the french language
lang={}
lang["it_s_a_sentence"]="C'est une phrase"
lang["Left"]="Gauche"
lang["Right"]="Droite"
lang["Up"]="Haut"
lang["Down"]="Bas"
lang["Settings"]="Paramètres"
import languages/lang.fr-FR.ini
Là, je connais pas cette partie en python... il faut peut-être que ton fichier s'appelle en .py et que tu l'utilises via un objet, je te laisse voir...[/QUOTE]# language file
# this is the french language
# initialisation
lang={}
# sentences used in the arena gameplay
lang["it_s_a_sentence"]="C'est une phrase"
# sentences used in the general menu
lang["Left"]="Gauche"
lang["Right"]="Droite"
lang["Up"]="Haut"
lang["Down"]="Bas"
lang["Settings"]="Paramètres"
# language file
# this is the english language
# initialisation
lang={}
# sentences used in the arena gameplay
lang["it_s_a_sentence"]="It's a sentence"
# sentences used in the general menu
lang["Left"]="Left"
lang["Right"]="Right"
lang["Up"]="Up"
lang["Down"]="Down"
lang["Settings"]="Settings"
# language file
# this is the english language
# initialisation
lang={}
# sentences used in the arena gameplay
lang["it_s_a_sentence"]="Es una frase"
# sentences used in the general menu
lang["Left"]="Izquierda"
lang["Right"]="Derecha"
lang["Up"]="Altura"
lang["Down"]="Bajo"
lang["Settings"]="Ajustes"
lang_file=fr-FR
lang_file=us-GB
lang_filename = "languages/lang." + lang_file + ".ini"
import lang_filename
import lang.py
lang_filename = "languages/lang." + lang_file + ".ini"
[b]import languages/lang.us-GB.ini[/b]
import lang_filename
Ainsi, tu commences par initialiser toutes tes phrases en anglais, puis tu écrases celles qui sont traduites par la langue du joueur. De cette façon tu auras toujours la totalité des phrases, même si ton traducteur n'a fait qu'une traduction partielle