Exemplo n.º 1
0
        private void PopulateRepeater()
        {
            string[] availableCultures = Formatting.SupportedCultures;

            Dictionary <string, string> specialNameLookup = new Dictionary <string, string>();
            Dictionary <string, bool>   suppressLookup    = new Dictionary <string, bool>();

            specialNameLookup["sr-Cyrl-RS"] = "Српски (ћирилица)";
            specialNameLookup["sr-Latn-RS"] = "Srpski (latinica)";
            specialNameLookup["es-VE"]      = "Español (Venezuela)";

            suppressLookup["en-US"] = true;
            suppressLookup["zh-CN"] = true;
            // suppressLookup["ar-SA"] = true;

            List <LanguageParameters> availableLanguages = new List <LanguageParameters>();

            foreach (string cultureId in availableCultures)
            {
                if (suppressLookup.ContainsKey(cultureId))
                {
                    continue;
                }

                LanguageParameters newLanguage = new LanguageParameters();
                newLanguage.CultureId = cultureId;
                CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureId);

                if (specialNameLookup.ContainsKey(cultureId))
                {
                    newLanguage.DisplayName = specialNameLookup[cultureId];
                }
                else
                {
                    newLanguage.DisplayName = culture.NativeName;
                    newLanguage.DisplayName = Char.ToUpperInvariant(newLanguage.DisplayName[0]) +
                                              newLanguage.DisplayName.Substring(1); // Capitalize

                    // Do not display country, just the language name
                    newLanguage.DisplayName = newLanguage.DisplayName.Substring(0, newLanguage.DisplayName.IndexOf(" (")).Trim();
                }

                newLanguage.IconUrl = SupportFunctions.FlagFileFromCultureId(cultureId);

                if (culture.TextInfo.IsRightToLeft)
                {
                    newLanguage.Rtl = "rtl";
                }

                availableLanguages.Add(newLanguage);
            }

            this.RepeaterLanguages.DataSource = availableLanguages;
            this.RepeaterLanguages.DataBind();
        }
Exemplo n.º 2
0
        private void Localize()
        {
            this.LabelSidebarInfo.Text    = Global.Sidebar_Information;
            this.LabelSidebarActions.Text = Global.Sidebar_Actions;
            this.LabelSidebarTodo.Text    = Global.Sidebar_Todo;

            string cultureString      = Thread.CurrentThread.CurrentCulture.ToString();
            string cultureStringLower = cultureString.ToLowerInvariant();

            if (cultureStringLower == "en-us")
            {
                cultureString      = "en-US";
                cultureStringLower = "en-us";
                Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureString);

                HttpCookie cookieCulture = new HttpCookie("PreferredCulture");
                cookieCulture.Value   = cultureString;
                cookieCulture.Expires = DateTime.Now.AddDays(365);
                Response.Cookies.Add(cookieCulture);
            }


            if (cultureStringLower == "af-za") // "South African Afrikaans", a special placeholder for localization code
            {
                InitTranslation();
            }
            else
            {
                this.LiteralCrowdinScript.Text = string.Empty;
            }

            this.ImageCultureIndicator.ImageUrl = SupportFunctions.FlagFileFromCultureId(cultureString);

            this.LinkLogout.Text       = Global.CurrentUserInfo_Logout;
            this.LabelPreferences.Text = Global.CurrentUserInfo_Preferences;
            // this.LiteralCurrentlyLoggedIntoSwitch.Text = string.Format(Resources.Global.Master_SwitchOrganizationDialog, _currentOrganization.Name);

            this.MasterLabelEditPersonHeaderAccount.Text = Resources.Global.Master_EditPersonHeaderAccount;
            this.MasterLabelEditPersonMail.Text          = Resources.Global.Global_Mail;
            this.MasterLabelEditPersonName.Text          = Resources.Global.Global_Name;
            this.MasterLabelEditPersonPhone.Text         = Resources.Global.Global_Phone;
            this.MasterLabelEditPersonTwitter.Text       = Resources.Global.Global_TwitterId;

            this.MasterLabelEditPersonHeaderSecurity.Text  = Resources.Global.Master_EditPersonHeaderSecurity;
            this.MasterLabelEditPerson2FA.Text             = Resources.Global.Master_EditPerson2FAEnable;
            this.MasterLabelEditPersonCurrentPassword.Text = Resources.Global.Master_EditPersonCurrentPassword;
            this.MasterLabelEditPersonNewPassword1.Text    = Resources.Global.Master_EditPersonNewPassword1;
            this.MasterLabelEditPersonNewPassword2.Text    = Resources.Global.Master_EditPersonNewPassword2;
            this.MasterEditPerson2FA.Label = Resources.Global.Master_EditPerson2FAEnableShort;

            this.MasterLabelEditPersonHeaderSecurityProvisioning.Text =
                Resources.Global.Master_EditPersonHeaderSecurityProvisioning;
            this.MasterEditPerson2FAProvisioning.Label     = Resources.Global.Master_EditPerson2FAEnableShort;
            this.MasterLabelEditPersonResetPassword.Text   = Resources.Global.Master_EditPersonResetPasswordLabel;
            this.MasterLabelEditPerson2FAProvisioning.Text = Resources.Global.Master_EditPerson2FAEnable;

            this.MasterLabelEditPersonHeaderPaymentHistory.Text    = Resources.Global.Financial_PaymentHistory;
            this.MasterPersonEditLiteralHeaderAmountOwed.Text      = Resources.Global.Financial_Owed;
            this.MasterPersonEditLiteralHeaderAmountPaid.Text      = Resources.Global.Financial_Paid;
            this.MasterPersonEditLiteralHeaderItemOpenedDate.Text  = Resources.Global.Global_Opened;
            this.MasterPersonEditLiteralHeaderItemClosedDate.Text  = Resources.Global.Global_Closed;
            this.MasterPersonEditLiteralHeaderItemNotes.Text       = Resources.Global.Global_Notes;
            this.MasterPersonEditLiteralHeaderItemName.Text        = Resources.Global.Global_Item;
            this.MasterPersonEditLiteralHeaderItemDescription.Text = Resources.Global.Global_Description;


            this.MasterLabelBitIdRegisterHeader.Text = Resources.Global.Master_BitIdRegister_Header;

            this.MasterLabelDashboardProfitLoss.Text = String.Format(Resources.Global.Financial_ProfitToDate,
                                                                     CurrentOrganization.Currency.DisplayCode);
        }
Exemplo n.º 3
0
        private static string AllCulturesAsJson()
        {
            StringBuilder             result               = new StringBuilder(16384);
            Dictionary <string, bool> cultureFullLookup    = new Dictionary <string, bool>();
            Dictionary <string, bool> culturePartialLookup = new Dictionary <string, bool>();

            string[] supportedCultures = Swarmops.Logic.Support.Formatting.SupportedCultures;
            foreach (string culture in supportedCultures)
            {
                cultureFullLookup[culture] = true;
                culturePartialLookup[culture.Substring(0, culture.IndexOf('-'))] = true;
            }

            string yesImage  = "<img src='/Images/Icons/iconshock-green-tick-128x96px.png' height='20' width='26' />";
            string halfImage = "<img src='/Images/Icons/iconshock-gold-tick-128x96px.png' height='18' width='24' />";
            string noImage   = "<img src='/Images/Icons/iconshock-red-cross-128x96px.png' height='10' width='13' />";

            result.Append("{\"rows\":[");

            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);

            foreach (CultureInfo culture in cultures)
            {
                // Don't display af-ZA because we're using af-ZA as a pseudoloc culture

                if (culture.Name == "af-ZA")
                {
                    continue;
                }

                RegionInfo region = null;

                try
                {
                    region = new RegionInfo(culture.Name);

                    string flagFile = SupportFunctions.FlagFileFromCultureId(culture.Name);

                    if (!File.Exists(HttpContext.Current.Server.MapPath("~" + flagFile)))
                    {
                        flagFile = string.Empty;
                    }
                    else
                    {
                        flagFile = "<img src='" + flagFile + "' height='24' width='24' />";
                    }

                    result.Append("{");
                    result.AppendFormat(
                        "\"cultureId\":\"{0}\",\"name\":\"{1}\",\"nameInternational\":\"{2}\",\"country\":\"{3}\",\"flag\":\"{4}\",\"supported\":\"{5}\"",
                        culture.Name,
                        culture.NativeName,
                        culture.EnglishName,
                        region.EnglishName,
                        flagFile.Length > 2? flagFile : noImage,
                        cultureFullLookup.ContainsKey(culture.Name)? yesImage: culturePartialLookup.ContainsKey(culture.Name.Substring(0, culture.Name.IndexOf('-')))? halfImage: noImage
                        );

                    result.Append("},");
                }
                catch
                {
                    continue;
                }
            }

            result.Remove(result.Length - 1, 1); // remove last comma
            result.Append("]}");

            return(result.ToString());
        }