Example #1
0
    private void Awake()
    {
        if (singleton == null)
        {
            singleton = this;
        }

        languagesAsset = Resources.Load(languagesPath + "/languages") as TextAsset;
        LanguagesList languagesList = JsonUtility.FromJson <LanguagesList>(languagesAsset.text);

        if (languagesList == null)
        {
            Debug.LogError("Could not read the languages json");
        }


        foreach (string lang in languagesList.langList)
        {
            TextAsset langAsset = Resources.Load(languagesPath + "/" + lang) as TextAsset;
            Language  language  = JsonUtility.FromJson <Language>(langAsset.text);
            if (language != null)
            {
                languages.Add(language);
            }
        }

        Language defaultLang = languages.Find(lang => lang.shortName == defaultLanguage);

        if (defaultLang != null)
        {
            currentLanguage = defaultLang;
        }
    }
 public SettingsProcessor(GroupDatabaseService database, IOptions <LanguagesList> languages)
 {
     _database  = database;
     _languages = languages.Value;
     // TODO: Refactor it
     Program.Languages = languages.Value;
 }
Example #3
0
        public static async Task SendAllLocalization()
        {
            //looking for a root directory
            string curDir = Directory.GetCurrentDirectory();

            while (!Directory.Exists(curDir + "\\ColonyRuler"))
            {
                int pos = curDir.Length - 1;
                while (curDir[pos] != '\\')
                {
                    pos--;
                }

                curDir = curDir.Substring(0, pos);
            }

            string gameDir = curDir + "\\ColonyRuler";

            Directory.SetCurrentDirectory(gameDir);

            var jsonText = File.ReadAllText(gameDir + "\\" + Localization.CLangListPath);

            LanguagesList languages = JsonConvert.DeserializeObject <LanguagesList>(jsonText);

            gameDir += "\\Assets\\Resources\\";
            Directory.SetCurrentDirectory(gameDir);

            foreach (var lang in languages.m_languages)
            {
                await SendLocalization(lang);
            }
        }
Example #4
0
    /// <summary>
    /// Create EN localization from current
    /// </summary>
    public void CreateFiles()
    {
        m_languages = new LanguagesList();
        m_languages.m_languages.Add("EN_en");
        m_languages.m_languages.Add("RU_ru");
        File.WriteAllText(CLangListPath, JsonUtility.ToJson(m_languages));
        if (m_history == null)
        {
            m_history = new HistoryLocalization();
        }
        if (m_items == null)
        {
            m_items = new ItemsLocalization();
        }
        if (m_ui == null)
        {
            m_ui = new UiLocalization();
        }

        foreach (AbstractObject itm in AbstractObject.m_sEverything)
        {
            m_items.m_itemList.Add(new LocalizationItem(itm.m_name, itm.m_text));
        }

        m_items.m_itemDictionary = new Dictionary <string, string>();
        foreach (LocalizationItem itm in m_items.m_itemList)
        {
            m_items.m_itemDictionary.Add(itm.m_name, itm.m_text);
        }

        CombinePath();
        File.WriteAllText(m_sHistoryFullPath + ".json", JsonUtility.ToJson(m_history));
        File.WriteAllText(m_sItemsFullPath + ".json", JsonUtility.ToJson(m_items));
        File.WriteAllText(m_sUiFullPath + ".json", JsonUtility.ToJson(m_ui));
    }
Example #5
0
        /// <summary>
        /// Binds the languages repeater.
        /// </summary>
        /// <returns></returns>
        private void BindTaxLanguagesList()
        {
            DataTable sourceTable = new DataTable();

            sourceTable.Columns.AddRange(new DataColumn[] {
                new DataColumn("LanguageCode", typeof(string)),
                new DataColumn("FriendlyName", typeof(string)),
                new DataColumn("DisplayName", typeof(string))
            });

            DataTable dtLanguages = Language.GetAllLanguagesDT();

            if (TaxId > 0 && _TaxDto.Tax.Count > 0)
            {
                foreach (DataRow row in dtLanguages.Rows)
                {
                    string langCode = row["LangName"].ToString();

                    TaxDto.TaxLanguageRow taxLanguageRow = null;

                    // check if record for the current language already exists in TaxLanguage table
                    TaxDto.TaxLanguageRow[] taxLanguageRows = (TaxDto.TaxLanguageRow[])_TaxDto.TaxLanguage.Select(String.Format("LanguageCode='{0}'", langCode));
                    if (taxLanguageRows != null && taxLanguageRows.Length > 0)
                    {
                        taxLanguageRow = taxLanguageRows[0];
                    }
                    else
                    {
                        taxLanguageRow = _TaxDto.TaxLanguage.NewTaxLanguageRow();
                        taxLanguageRow.LanguageCode = langCode;
                        taxLanguageRow.TaxId        = _TaxDto.Tax[0].TaxId;
                        taxLanguageRow.DisplayName  = String.Empty;
                    }

                    // add taxLanguage to the source table
                    DataRow sourceTableRow = sourceTable.NewRow();
                    sourceTableRow["LanguageCode"] = taxLanguageRow.LanguageCode;
                    sourceTableRow["FriendlyName"] = (string)row["FriendlyName"];
                    sourceTableRow["DisplayName"]  = taxLanguageRow.DisplayName;
                    sourceTable.Rows.Add(sourceTableRow);
                }
            }
            else
            {
                // this is a new tax, bind empty table
                foreach (DataRow row in dtLanguages.Rows)
                {
                    string langCode = row["LangName"].ToString();

                    DataRow sourceTableRow = sourceTable.NewRow();
                    sourceTableRow["LanguageCode"] = langCode;
                    sourceTableRow["FriendlyName"] = (string)row["FriendlyName"];
                    sourceTableRow["DisplayName"]  = String.Empty;
                    sourceTable.Rows.Add(sourceTableRow);
                }
            }

            LanguagesList.DataSource = sourceTable;
            LanguagesList.DataBind();
        }
Example #6
0
 private bool CanAdd(object obj)
 {
     if (string.IsNullOrEmpty(currentCandidate.Name) || string.IsNullOrEmpty(currentCandidate.Surname) ||
         string.IsNullOrEmpty(currentCandidate.MidleName) || string.IsNullOrEmpty(currentCandidate.Phone) ||
         string.IsNullOrEmpty(currentCandidate.Address) || string.IsNullOrEmpty(currentCandidate.MaritalStatus) ||
         string.IsNullOrEmpty(currentCandidate.Education) || currentCandidate.Age < 18 || currentCandidate.Age > 65 ||
         !currentCandidate.IsValidEmail || !ProgrammingLanguagesList.Where(x => x.IsChecked == true).Any() ||
         Candidates.Where(x => x.Id == currentCandidate.Id).Any() || !FrameworksList.Where(x => x.IsChecked == true).Any() ||
         !LanguagesList.Where(x => x.IsChecked == true).Any())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #7
0
    /// <summary>
    /// Only first initialization on the game startup
    /// </summary>
    public void FirstLoad()
    {
#if !UNITY_WEBGL && !UNITY_ANDROID
        if (!File.Exists(CLangListPath))
        {
            CreateFiles();
        }

        m_languages = JsonUtility.FromJson <LanguagesList>(File.ReadAllText(CLangListPath));
#else
        if (m_languages == null || m_languages.m_languages == null)
        {
            var ms         = Camera.main.GetComponent <MainScript>();
            var networking = ms.m_networking;

            networking.GetLocalizationLanguages(delegate(string answer)
            {
                m_languages = JsonUtility.FromJson <LanguagesList>(NetworkManager.ByteToJson(answer));
                Load();
            });
        }
#endif
    }
Example #8
0
        /// <summary>
        /// Binds the languages repeater.
        /// </summary>
        /// <returns></returns>
        private void BindPromotionLanguagesList()
        {
            DataTable sourceTable = new DataTable();

            sourceTable.Columns.AddRange(new DataColumn[] {
                new DataColumn("LanguageCode", typeof(string)),
                new DataColumn("FriendlyName", typeof(string)),
                new DataColumn("DisplayName", typeof(string))
            });

            DataTable dtLanguages = Language.GetAllLanguagesDT();

            if (_promotion != null && _promotion.PromotionLanguage.Count > 0)
            {
                //first check permissions
                //if permissions not present, deny
                SecurityManager.CheckRolePermission("marketing:promotions:mng:edit");

                foreach (DataRow row in dtLanguages.Rows)
                {
                    string langCode = row["LangName"].ToString();

                    PromotionDto.PromotionLanguageRow promoLanguageRow = null;

                    // check if record for the current language already exists in TaxLanguage table
                    PromotionDto.PromotionLanguageRow[] promoLanguageRows = (PromotionDto.PromotionLanguageRow[])_promotion.PromotionLanguage.Select(String.Format("LanguageCode='{0}'", langCode));
                    if (promoLanguageRows != null && promoLanguageRows.Length > 0)
                    {
                        promoLanguageRow = promoLanguageRows[0];
                    }
                    else
                    {
                        promoLanguageRow = _promotion.PromotionLanguage.NewPromotionLanguageRow();
                        promoLanguageRow.LanguageCode = langCode;
                        promoLanguageRow.PromotionId  = _promotion.Promotion[0].PromotionId;
                        promoLanguageRow.DisplayName  = String.Empty;
                    }

                    // add taxLanguage to the source table
                    DataRow sourceTableRow = sourceTable.NewRow();
                    sourceTableRow["LanguageCode"] = promoLanguageRow.LanguageCode;
                    sourceTableRow["FriendlyName"] = (string)row["FriendlyName"];
                    sourceTableRow["DisplayName"]  = promoLanguageRow.DisplayName;
                    sourceTable.Rows.Add(sourceTableRow);
                }
            }
            else
            {
                //first check permissions
                //if permissions not present, deny
                SecurityManager.CheckRolePermission("marketing:promotions:mng:create");

                // this is a new tax, bind empty table
                foreach (DataRow row in dtLanguages.Rows)
                {
                    string langCode = row["LangName"].ToString();

                    DataRow sourceTableRow = sourceTable.NewRow();
                    sourceTableRow["LanguageCode"] = langCode;
                    sourceTableRow["FriendlyName"] = (string)row["FriendlyName"];
                    sourceTableRow["DisplayName"]  = String.Empty;
                    sourceTable.Rows.Add(sourceTableRow);
                }
            }

            LanguagesList.DataSource = sourceTable;
            LanguagesList.DataBind();
        }