Exemplo n.º 1
0
    //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 Traduction AddTraduction(SystemLanguage _language)
        {
            Traduction _traduction = new Traduction(_language);

            otherTraductions.Add(_traduction);
            return(_traduction);
        }
 public void UpdateLanguage(Traduction _traduction)
 {
     otherTraductions.Add(currentTraduction);
     currentTraduction = _traduction;
     otherTraductions.Remove(_traduction);
     text = currentTraduction.text;
 }
        public async Task <IHttpActionResult> PutTraduction(int id, Traduction traduction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != traduction.IdTraduction)
            {
                return(BadRequest());
            }

            db.Entry(traduction).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TraductionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 5
0
    //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 async Task <IHttpActionResult> GetTraduction(int id)
        {
            Traduction traduction = await db.Traduction.FindAsync(id);

            if (traduction == null)
            {
                return(NotFound());
            }

            return(Ok(traduction));
        }
        public async Task <IHttpActionResult> PostTraduction(Traduction traduction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Traduction.Add(traduction);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = traduction.IdTraduction }, traduction));
        }
        public async Task <IHttpActionResult> DeleteTraduction(int id)
        {
            Traduction traduction = await db.Traduction.FindAsync(id);

            if (traduction == null)
            {
                return(NotFound());
            }

            db.Traduction.Remove(traduction);
            await db.SaveChangesAsync();

            return(Ok(traduction));
        }
    public override void OnInspectorGUI()
    {
        MultiLanguageText multiLanguageText = (MultiLanguageText)target;

        //SHOW THE CURRENT TRADUCTION IN EDITOR//
        GUILayout.Label("Current traduction: " + multiLanguageText.currentTraduction.language.ToString(), EditorStyles.boldLabel);
        base.OnInspectorGUI();

        //ASSIGN THE EDITOR TEXT TO THE OBJECT//
        multiLanguageText.currentTraduction.text = multiLanguageText.text;

        //SHOW OTHER TRADUCTIONS//
        GUILayout.Label("Traductions", EditorStyles.boldLabel);
        foreach (Traduction _traduction in multiLanguageText.otherTraductions)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select " + _traduction.language.ToString()))
            {
                multiLanguageText.UpdateLanguage(_traduction);
                Repaint();
                return;
            }
            else if (GUILayout.Button("Remove " + _traduction.language.ToString()))
            {
                multiLanguageText.RemoveTraduction(_traduction);
                return;
            }
            GUILayout.EndHorizontal();
        }

        //ADD LANGUAGE//
        SystemLanguage newLanguage = multiLanguageText.currentTraduction.language;

        newLanguage = (SystemLanguage)EditorGUILayout.EnumPopup("Add", newLanguage);
        if (newLanguage != multiLanguageText.currentTraduction.language)
        {
            Traduction newTraduction = multiLanguageText.AddTraduction(newLanguage);
            multiLanguageText.UpdateLanguage(newTraduction);
            Repaint();
            return;
        }
    }
 public void RemoveTraduction(Traduction _traduction)
 {
     otherTraductions.Remove(_traduction);
 }