Ejemplo n.º 1
0
        public List <SimpleTranslation> LoadTextRepository()
        {
            SqlCommand sqlCommand      = null;
            var        translationList = new List <SimpleTranslation>();

            try
            {
                // Searching all repository
                sqlCommand = new SqlCommand("SELECT * FROM TEXT_TRANSLATIONS ORDER BY DOM_ELEMENT_ID");

                DataSet           dataSet           = SQLOperation.ExecuteSQLCommandWithResult(sqlCommand);
                SimpleTranslation simpleTranslation = new SimpleTranslation();

                int contRows = 0;
                do
                {
                    // Running all content, and build the repository.
                    if (simpleTranslation.DOMElementID != dataSet.Tables[0].Rows[contRows]["DOM_ELEMENT_ID"].ToString())
                    {
                        if (simpleTranslation.DOMElementID != null)
                        {
                            //Save the last translation repository
                            translationList.Add(simpleTranslation);
                        }

                        simpleTranslation = new SimpleTranslation();
                        simpleTranslation.DOMElementID = dataSet.Tables[0].Rows[contRows]["DOM_ELEMENT_ID"].ToString();
                    }

                    // Now, set the translation
                    if (dataSet.Tables[0].Rows[contRows]["IDIOM"].ToString() == "PT")
                    {
                        simpleTranslation.PortugueseContent = dataSet.Tables[0].Rows[contRows]["TRANSLATION"].ToString();
                    }
                    else
                    {
                        simpleTranslation.EnglishContent = dataSet.Tables[0].Rows[contRows]["TRANSLATION"].ToString();
                    }

                    contRows++;
                } while (contRows < dataSet.Tables[0].Rows.Count);

                //Save the last translation repository
                translationList.Add(simpleTranslation);

                // With the translation repository complete, generate the JSON format
                return(translationList);
            }
            catch (Exception e) // Em qualquer caso de erro, retornar nulo.
            {
                return(null);
            }
            finally
            {
                // In all errors, return null
                sqlCommand.Dispose();
            }
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        string filePath = (Application.dataPath + "/").Replace("/", "\\");
        string fileName = "Translation.xml";

        Debug.Log(filePath + fileName);
        translation = new SimpleTranslation(filePath, fileName, "english");
        //translation = new SimpleTranslation(filePath, fileName);

        Debug.Log(translation.GetLanguages()[0]);

        translation.SetLanguage(language.ToString());
    }