//recupere les traductions de la langue actuelle public Langage readFile(string Language) { Langage l_lang = new Langage(); l_lang.langue = Language; l_lang.trads = new List <Traduction>(); if (!checkFile(Language)) { return(new Langage()); } string[] lines = System.IO.File.ReadAllLines(Application.streamingAssetsPath + Constants.langDirectory + Language + ".txt"); foreach (string line in lines) { if (!(line.Contains("#"))) { string [] tmp = line.Split('='); Traduction l_tmp = new Traduction(); l_tmp.cle = tmp[0].Replace("\t", ""); l_tmp.valeur = tmp[1]; l_lang.trads.Add(l_tmp); } } return(l_lang); }
public string GetTranslation(Langage lang) { switch (lang) { case Langage.English: return(english); case Langage.Allemand: return(allemand); case Langage.Francais: return(francais); case Langage.Espagnol: return(espagnol); case Langage.Italien: return(italien); case Langage.Portugais: return(portugais); default: return(""); } }
//applique la traduction a l'objet rattaché public void applyTradToscene(string Language) { Langage l = langues.Find(i => i.langue.Equals(Language)); Traduction t = l.trads.Find(k => k.cle.Equals(conteneur.GetComponent <Text>().text)); if (t.cle != null) { print(t.cle + " traduit par " + t.valeur); conteneur.gameObject.GetComponent <Text>().text = t.valeur; } }
public void Initsentence() { // chois entre hotel et resto isHotel = UnityEngine.Random.Range(0, 2) < 1; // chois phrase if (isHotel) { HotelSettings hotel = hotels[UnityEngine.Random.Range(0, hotels.Count)]; goodHotelName = hotel.name; fullSentenses[0] = string.Format(sentenseHotel[UnityEngine.Random.Range(0, sentenseHotel.Count)], "<color=red>" + sentenseHotelWords[UnityEngine.Random.Range(0, sentenseHotelWords.Count)] + "<color=white>"); fullSentenses[1] = (string.Format(sentenseHotelRoom[UnityEngine.Random.Range(0, sentenseHotelRoom.Count)], "<color=red>" + hotel.rooms[UnityEngine.Random.Range(0, hotel.rooms.Count)] + "<color=white>")); fullSentenses[2] = (string.Format(sentenseVisual[UnityEngine.Random.Range(0, sentenseVisual.Count)], "<color=red>" + hotel.visual + "<color=white>")); fullSentenses[3] = (string.Format(sentenseDate[UnityEngine.Random.Range(0, sentenseDate.Count)], "<color=red>" + hotel.jours[0] + "<color=white>", "<color=red>" + hotel.jours[1] + "<color=white>")); fullSentenses[4] = (string.Format(sentensePrise[UnityEngine.Random.Range(0, sentensePrise.Count)], "<color=red>" + hotel.prix + "<color=white>")); fullSentenses[5] = (string.Format(sentenseFake[UnityEngine.Random.Range(0, sentenseFake.Count)])); langue = hotel.langages[UnityEngine.Random.Range(0, hotel.langages.Count)]; } else { RestoSettings resto = restos[UnityEngine.Random.Range(0, restos.Count)]; goodHotelName = resto.name; fullSentenses[0] = (string.Format(sentenseResto[UnityEngine.Random.Range(0, sentenseResto.Count)], "<color=red>" + sentenseRestoWords[UnityEngine.Random.Range(0, sentenseRestoWords.Count)] + "<color=white>")); fullSentenses[1] = (string.Format(sentenseRestoMenu[UnityEngine.Random.Range(0, sentenseRestoMenu.Count)], "<color=red>" + resto.menus[UnityEngine.Random.Range(0, resto.menus.Count)] + "<color=white>")); fullSentenses[2] = (string.Format(sentenseVisual[UnityEngine.Random.Range(0, sentenseVisual.Count)], "<color=red>" + resto.visual + "<color=white>")); fullSentenses[3] = (string.Format(sentenseDate[UnityEngine.Random.Range(0, sentenseDate.Count)], "<color=red>" + resto.jours[UnityEngine.Random.Range(0, resto.jours.Count)] + "<color=white>")); fullSentenses[4] = (string.Format(sentensePrise[UnityEngine.Random.Range(0, sentensePrise.Count)], "<color=red>" + resto.prix + "<color=white>")); fullSentenses[5] = (string.Format(sentenseFake[UnityEngine.Random.Range(0, sentenseFake.Count)])); langue = resto.langages[UnityEngine.Random.Range(0, resto.langages.Count)]; } // randomiser l'array usableSentense = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n", fullSentenses[0], fullSentenses[1], fullSentenses[2], fullSentenses[3], fullSentenses[4], fullSentenses[5]); }
/// <summary> /// Constructeur /// </summary> /// <param name="lang"></param> /// <param name="data"></param> public BundleDTO(Langage lang, string data) : this() { Data.Add(lang, data); }
/// <summary> /// Recherche de code. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonChercherClick(object sender, EventArgs e) { progressBarGoingForward = true; timer1.Enabled = true; if (string.IsNullOrEmpty(textBoxChercher.Text)) { MessageBox.Show("Vous devez entrez au moins un mot clef à chercher.\n\n Entrez un ou plusieurs mots clefs séparés par des espaces.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (NumberOfCheckBoxChecked() == 0) { MessageBox.Show("Vous devez cocher au moins un langage.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // récupération des options cochées // est-ce que le pc est connecté à internet ? // On parcours le fichier ou bien on charge tout le fichier en RAM (depending on the length of the file) if (!File.Exists(FichierCodeRepo)) { CreateNewFile(FichierCodeRepo); } // var sr = new StreamReader(FichierCodeRepo); // leCode = string.Empty; // leCode = sr.ReadToEnd(); // sr.Close(); fctb.Text = string.Empty; listBoxResult.Items.Clear(); // Recherche des mots clefs dans la chaine LeCode var contenuFichier = new List <string>(); using (var sr2 = new StreamReader(FichierCodeRepo)) { while (!sr2.EndOfStream) { // On copie le fichier source texte dans une liste de string ligne par ligne. contenuFichier.Add(sr2.ReadLine()); } } string[] listMotClef = textBoxChercher.Text.Split(' '); var listLangageCoches = new List <string>(); // or var listLangageCoches = (from Control controle in groupBoxLangage.Controls where controle is CheckBox && ((CheckBox)controle).Checked select ((CheckBox)controle).Name).ToList(); foreach (Control controle in groupBoxLangage.Controls) { if (controle is CheckBox && ((CheckBox)controle).Checked) { listLangageCoches.Add(controle.Name); } } // Séparation des codes par langages var listCSharp = new List <string>(); var listVbNet = new List <string>(); var listPhp = new List <string>(); var listVba = new List <string>(); var listHtml = new List <string>(); var listCss = new List <string>(); var listSql = new List <string>(); var listJscript = new List <string>(); var listPython = new List <string>(); var listRuby = new List <string>(); var listJava = new List <string>(); var listDelphi = new List <string>(); var listVbs = new List <string>(); var listCpp = new List <string>(); var listPowerShell = new List <string>(); bool codeEnCours = false; string codeTemp = string.Empty; Langage langageEnCours = Langage.Nothing; foreach (string ligneCode in contenuFichier) { if (codeEnCours && ligneCode != "[end]") { codeTemp += ligneCode + "\r\n"; } if (ligneCode == "[end]") { switch (langageEnCours) { case Langage.Csharp: listCSharp.Add(codeTemp); break; case Langage.Powershell: listPowerShell.Add(codeTemp); break; case Langage.Vba: listVba.Add(codeTemp); break; case Langage.Vbnet: listVbNet.Add(codeTemp); break; case Langage.Php: listPhp.Add(codeTemp); break; case Langage.Html: listHtml.Add(codeTemp); break; case Langage.Css: listCss.Add(codeTemp); break; case Langage.Sql: listSql.Add(codeTemp); break; case Langage.Js: listJscript.Add(codeTemp); break; case Langage.Python: listPython.Add(codeTemp); break; case Langage.Ruby: listRuby.Add(codeTemp); break; case Langage.Java: listJava.Add(codeTemp); break; case Langage.Delphi: listDelphi.Add(codeTemp); break; case Langage.Cpp: listCpp.Add(codeTemp); break; case Langage.Vbs: listVbs.Add(codeTemp); break; } codeEnCours = false; codeTemp = string.Empty; langageEnCours = Langage.Nothing; } if (ligneCode == "[start]") { codeEnCours = true; } Langage langueTmp = WhatLanguageFor(ligneCode); if (langueTmp != Langage.Nothing) { codeTemp = string.Empty; langageEnCours = langueTmp; } } // Recherche du mot clef dans les listes. // On a des mots clefs dans listLangageCoches FillListBoxResultIfNotEmpty(listCSharp, listLangageCoches.Contains("checkBox" + Language.CSharp), Language.CSharp); FillListBoxResultIfNotEmpty(listVbNet, listLangageCoches.Contains("checkBox" + Langage.Vbnet.ToString().ToUpper()), Language.VB); FillListBoxResultIfNotEmpty(listVba, listLangageCoches.Contains("checkBox" + Langage.Vba.ToString().ToUpper()), Language.VBA); FillListBoxResultIfNotEmpty(listPowerShell, listLangageCoches.Contains("checkBox" + Langage.Powershell), Language.Powershell); FillListBoxResultIfNotEmpty(listPhp, listLangageCoches.Contains("checkBox" + Langage.Php), Language.PHP); FillListBoxResultIfNotEmpty(listHtml, listLangageCoches.Contains("checkBox" + Langage.Html.ToString().ToUpper()), Language.HTML); FillListBoxResultIfNotEmpty(listCss, listLangageCoches.Contains("checkBox" + Langage.Css.ToString().ToUpper()), Language.CSS); FillListBoxResultIfNotEmpty(listJscript, listLangageCoches.Contains("checkBox" + Langage.Js.ToString().ToUpper()), Language.JS); FillListBoxResultIfNotEmpty(listSql, listLangageCoches.Contains("checkBox" + Langage.Sql.ToString().ToUpper()), Language.SQL); FillListBoxResultIfNotEmpty(listPython, listLangageCoches.Contains("checkBox" + Langage.Python), Language.Python); FillListBoxResultIfNotEmpty(listRuby, listLangageCoches.Contains("checkBox" + Langage.Ruby), Language.Ruby); FillListBoxResultIfNotEmpty(listCpp, listLangageCoches.Contains("checkBox" + Langage.Cpp), Language.Cpp); FillListBoxResultIfNotEmpty(listJava, listLangageCoches.Contains("checkBox" + Langage.Java), Language.Java); FillListBoxResultIfNotEmpty(listDelphi, listLangageCoches.Contains("checkBox" + Langage.Delphi), Language.Delphi); FillListBoxResultIfNotEmpty(listVbs, listLangageCoches.Contains("checkBox" + Langage.Vbs.ToString().ToUpper()), Language.Vbs); if (listBoxResult.Items.Count != 0) { listBoxResult.SetSelected(0, true); } labelResultat.Text = string.Format("Résultat: " + listBoxResult.Items.Count); toolStripProgressBar1.Value = toolStripProgressBar1.Minimum; timer1.Enabled = false; }
// Start is called before the first frame update void Start() { nameClient = GameManager.instance.randomName[UnityEngine.Random.Range(0, GameManager.instance.randomName.Count)].Split(fieldSeparator, StringSplitOptions.None);; language = GameManager.instance.langue; }
private string CreationClassePersistable(ICodeGenerator codeGenerator, Langage langageChoice) { // namespace DB + nom de la base de données CodeNamespace monNamespace = new CodeNamespace("DB_" + (trvSqlServerSchema.SelectedNode.Parent.Tag as SQLDMO._Database).Name); // ajout des imports de namespace monNamespace.Imports.Add(new CodeNamespaceImport("System")); monNamespace.Imports.Add(new CodeNamespaceImport("System.Data")); monNamespace.Imports.Add(new CodeNamespaceImport("SableFin.SfinX.SimplePersistance")); // creation de la classe SQLDMO._Table tab=trvSqlServerSchema.SelectedNode.Tag as SQLDMO._Table; CodeTypeDeclaration maClasse = new CodeTypeDeclaration(tab.Name); //maClasse.BaseTypes.Add(tab.Name); maClasse.Attributes = MemberAttributes.Public; maClasse.IsClass = true; maClasse.Comments.Add(new CodeCommentStatement("Persistable classes for the " + tab.Name + " table.", false)); // creation de l'attribut [PersistConnectionString] CodeAttributeDeclaration attr=new CodeAttributeDeclaration(); attr.Name="PersistConnectionString"; maClasse.CustomAttributes.Add(attr); if ((ConnectionStringIn)cboCnxStrIn.SelectedItem==ConnectionStringIn.ApplicationSettings) attr.Arguments.Add(new CodeAttributeArgument("AppSettingsName",new CodePrimitiveExpression("cnxstr"))); else attr.Arguments.Add(new CodeAttributeArgument("SessionVariable",new CodePrimitiveExpression("cnxstr"))); if ((DatasourceType)cboPDSA.SelectedItem==DatasourceType.SQLServerStoredProc) { // creation de l'attribut [PersistStoredProc] attr=new CodeAttributeDeclaration(); attr.Name="PersistStoredProc"; attr.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression("spS_" + tab.Name))); attr.Arguments.Add(new CodeAttributeArgument("INSERTStoredProc",new CodePrimitiveExpression("spI_" + tab.Name))); attr.Arguments.Add(new CodeAttributeArgument("DELETEStoredProc",new CodePrimitiveExpression("spD_" + tab.Name))); attr.Arguments.Add(new CodeAttributeArgument("UPDATEStoredProc",new CodePrimitiveExpression("spU_" + tab.Name))); attr.Arguments.Add(new CodeAttributeArgument("TableName",new CodePrimitiveExpression(tab.Name))); } else if ((DatasourceType)cboPDSA.SelectedItem==DatasourceType.DynamicSQL) { // creation de l'attribut [PersistDynamicSQL] attr=new CodeAttributeDeclaration(); attr.Name="PersistDynamicSQL"; attr.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(tab.Name))); } maClasse.CustomAttributes.Add(attr); monNamespace.Types.Add(maClasse); // ajout de la classe dans le namespace for(int n=1;n<=tab.Columns.Count;n++) { SQLDMO._Column col=tab.Columns.Item(n); Type dotNetType=GetDotNetType(col.PhysicalDatatype); // private string CodeMemberField priv_var = new CodeMemberField(dotNetType, "p_" + col.Name); maClasse.Members.Add(priv_var ); // private bool si Nullable col CodeMemberField null_var=null; if (col.AllowNulls) { null_var=new CodeMemberField(typeof(bool),col.Name + "ISNULL"); null_var.Attributes=MemberAttributes.Public | MemberAttributes.Final; null_var.InitExpression=new CodePrimitiveExpression(true); maClasse.Members.Add(null_var); } // definition d'une reference a une variable CodeFieldReferenceExpression ref_var = null; ref_var = new CodeFieldReferenceExpression(); ref_var.TargetObject = new CodeThisReferenceExpression(); ref_var.FieldName = priv_var.Name; CodeFieldReferenceExpression ref_null_var=null; if (col.AllowNulls) { ref_null_var = new CodeFieldReferenceExpression(); ref_null_var.TargetObject = new CodeThisReferenceExpression(); ref_null_var.FieldName = null_var.Name; } CodeMemberProperty champDB = new CodeMemberProperty(); champDB.Attributes = MemberAttributes.Public | MemberAttributes.Final; champDB.Type = new CodeTypeReference(dotNetType); champDB.Name = col.Name; champDB.HasGet = true; champDB.HasSet = true; CodeMethodReturnStatement returnRefThis = new CodeMethodReturnStatement(ref_var); champDB.GetStatements.Add(returnRefThis); CodeAssignStatement setField=new CodeAssignStatement(ref_var,new CodePropertySetValueReferenceExpression()); champDB.SetStatements.Add(setField); if (col.AllowNulls) { CodeAssignStatement setFieldIsNullToFalse=new CodeAssignStatement(ref_null_var,new CodePrimitiveExpression(false)); champDB.SetStatements.Add(setFieldIsNullToFalse); } // création de l'attribut pour la propriété en cours attr=new CodeAttributeDeclaration(); attr.Name="DBField"; attr.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(col.Name))); if (col.InPrimaryKey) { attr.Arguments.Add(new CodeAttributeArgument("PrimaryKey", new CodePrimitiveExpression(true))); } if (col.Identity) { attr.Arguments.Add(new CodeAttributeArgument("Identity", new CodePrimitiveExpression(true))); } if (col.AllowNulls) { attr.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true))); //attr.Arguments.Add(new CodeAttributeArgument("NullValue", new CodePrimitiveExpression(GetDefaultValueForNull(col.PhysicalDatatype)))); } champDB.CustomAttributes.Add(attr); // ajout de l'attribut sur la prop maClasse.Members.Add(champDB); // ajout de la propriété dans la classe } // On génère finalement le code System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); TextWriter textWriter = new StringWriter(stringBuilder); try { codeGenerator.GenerateCodeFromNamespace(monNamespace, textWriter, null); } catch (Exception exception) { return(exception.ToString()); } finally { textWriter.Close(); } return(stringBuilder.ToString()); }