private void AggregateData() { Locale.Zones?.ForEach(zone => zone.Positions?.ForEach(position => { position.Zone = zone; position.PositionSignalData?.ForEach(data => { data.Position = position; LocaleData.Add(data); }); })); SignalNames = LocaleData .Where(data => data.SignalType != SignalType.Magnetometer && !string.IsNullOrEmpty(data.SignalId)) .GroupBy(data => data.SignalId) .Select(data => new { SignalId = data.Key, Samples = data.Sum(positionSignalData => positionSignalData.Samples) }) .OrderByDescending(signal => signal.Samples) .Select(signal => signal.SignalId) .ToHashSet(); }
public void SaveStrings(List <LocalizedString> locales, IStream stream) { if (LocaleData == null || LocaleIndexTable == null) { return; } using (var offsetData = new MemoryStream()) using (var stringData = new MemoryStream()) using (var offsetWriter = new EndianWriter(offsetData, stream.Endianness)) using (var stringWriter = new EndianWriter(stringData, stream.Endianness)) { // Write the string and offset data to buffers foreach (LocalizedString locale in locales) { WriteLocalePointer(offsetWriter, locale.Key, (int)stringWriter.Position); stringWriter.WriteUTF8(locale.Value); } // Round the size of the string data up var dataSize = (int)((stringData.Position + _sizeAlign - 1) & ~(_sizeAlign - 1)); stringData.SetLength(dataSize); // Make sure there's free space for the offset table and then write it to the file LocaleIndexTable.Resize((int)offsetData.Length, stream); stream.SeekTo(LocaleIndexTableLocation.AsOffset()); stream.WriteBlock(offsetData.ToArray(), 0, (int)offsetData.Length); byte[] strings = stringData.ToArray(); // Make sure there's free space for the string data and then write it to the file LocaleData.Resize(dataSize, stream); stream.SeekTo(LocaleDataLocation.AsOffset()); stream.WriteBlock(strings, 0, dataSize); // Update the string count and recalculate the language table offsets StringCount = locales.Count; } }
public static void Insert(LocaleData data) { // Create and execute the command string sql = "Insert Into " + TABLE + "(" + "LocaleCode," + "LocaleDescription," ; sql = sql.Substring(0, sql.Length - 1) + ") values(" + "@LocaleCode," + "@LocaleDescription," ; sql = sql.Substring(0, sql.Length - 1) + ")"; SqlCommand cmd = GetSqlCommand(DatabaseEnum.ORDERDB, sql, CommandType.Text, COMMAND_TIMEOUT); //Create the parameters and append them to the command object cmd.Parameters.Add(new SqlParameter("@LocaleCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "LocaleCode", DataRowVersion.Proposed, data.LocaleCode.DBValue)); cmd.Parameters.Add(new SqlParameter("@LocaleDescription", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "LocaleDescription", DataRowVersion.Proposed, data.LocaleDescription.DBValue)); // Execute the query cmd.ExecuteNonQuery(); }
void application_AcquireRequestState(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; HttpRequest request = application.Context.Request; _logger.DebugFormat(CultureInfo.InvariantCulture, "AcquireRequestState {0}", request.AppRelativeCurrentExecutionFilePath); var localeProvider = IocContainer.Instance.Resolve <ILocaleProvider>(); var webConfiguration = IocContainer.Instance.Resolve <IWebConfiguration>(); var trackingService = IocContainer.Instance.Resolve <ITrackingService>(); Identity identity = context.User.Identity as Identity; string langName = string.Empty; if (identity == null || string.IsNullOrEmpty(identity.Locale)) { //user not authenticated, first try is tracking cookie //if no cookie, use browser headers var trackingLocale = trackingService.GetTrackedLocaleName(context); if (trackingLocale != null) { langName = trackingLocale; } else if (request.UserLanguages != null && request.UserLanguages.Length != 0) { langName = request.UserLanguages[0].Substring(0, 2); } } else { langName = identity.Locale; } LocaleData locale = localeProvider.GetCultureByNameOrDefault(langName); localeProvider.SetThreadLocale(locale); }
private static LocaleData GetDataObjectFromReader(SqlDataReader dataReader) { LocaleData data = new LocaleData(); if (dataReader.IsDBNull(dataReader.GetOrdinal("LocaleCode"))) { data.LocaleCode = IdType.UNSET; } else { data.LocaleCode = new IdType(dataReader.GetInt32(dataReader.GetOrdinal("LocaleCode"))); } if (dataReader.IsDBNull(dataReader.GetOrdinal("LocaleDescription"))) { data.LocaleDescription = StringType.UNSET; } else { data.LocaleDescription = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("LocaleDescription"))); } return(data); }
public static void Update(LocaleData data) { // Create and execute the command LocaleData oldData = Load(data.LocaleCode); string sql = "Update " + TABLE + " set "; if (!oldData.LocaleCode.Equals(data.LocaleCode)) { sql = sql + "LocaleCode=@LocaleCode,"; } if (!oldData.LocaleDescription.Equals(data.LocaleDescription)) { sql = sql + "LocaleDescription=@LocaleDescription,"; } WhereClause w = new WhereClause(); w.And("LocaleCode", data.LocaleCode.DBValue); sql = sql.Substring(0, sql.Length - 1) + w.FormatSql(); SqlCommand cmd = GetSqlCommand(DatabaseEnum.ORDERDB, sql, CommandType.Text, COMMAND_TIMEOUT); //Create the parameters and append them to the command object if (!oldData.LocaleCode.Equals(data.LocaleCode)) { cmd.Parameters.Add(new SqlParameter("@LocaleCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "LocaleCode", DataRowVersion.Proposed, data.LocaleCode.DBValue)); } if (!oldData.LocaleDescription.Equals(data.LocaleDescription)) { cmd.Parameters.Add(new SqlParameter("@LocaleDescription", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "LocaleDescription", DataRowVersion.Proposed, data.LocaleDescription.DBValue)); } // Execute the query if (cmd.Parameters.Count > 0) { cmd.ExecuteNonQuery(); } }
private static string GetThreeLetterWindowsLanguageName(string cultureName) { string langName = LocaleData.GetThreeLetterWindowsLangageName(cultureName); return(langName == null ? "ZZZ" /* default lang name */ : langName); }
private static int GetGeoId(string cultureName) { int geoId = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.GeoId); return(geoId == -1 ? CultureData.Invariant.IGEOID : geoId); }
private static int GetMacCodePage(string cultureName) { int macCodePage = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.MacCodePage); return(macCodePage == -1 ? CultureData.Invariant.IDEFAULTMACCODEPAGE : macCodePage); }
private static int GetAnsiCodePage(string cultureName) { int ansiCodePage = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.AnsiCodePage); return(ansiCodePage == -1 ? CultureData.Invariant.IDEFAULTANSICODEPAGE : ansiCodePage); }
/// <summary> /// This method uses the sRealName field (which is initialized by the constructor before this is called) to /// initialize the rest of the state of CultureData based on the underlying OS globalization library. /// </summary> private unsafe bool InitCultureData() { Debug.Assert(_sRealName != null); Debug.Assert(!GlobalizationMode.Invariant); string alternateSortName = string.Empty; string realNameBuffer = _sRealName; // Basic validation if (realNameBuffer.Contains("@")) { return(false); // don't allow ICU variants to come in directly } // Replace _ (alternate sort) with @collation= for ICU int index = realNameBuffer.IndexOf('_'); if (index > 0) { if (index >= (realNameBuffer.Length - 1) || // must have characters after _ realNameBuffer.Substring(index + 1).Contains("_")) // only one _ allowed { return(false); // fail } alternateSortName = realNameBuffer.Substring(index + 1); realNameBuffer = realNameBuffer.Substring(0, index) + ICU_COLLATION_KEYWORD + alternateSortName; } // Get the locale name from ICU if (!GetLocaleName(realNameBuffer, out _sWindowsName)) { return(false); // fail } // Replace the ICU collation keyword with an _ index = _sWindowsName.IndexOf(ICU_COLLATION_KEYWORD, StringComparison.Ordinal); if (index >= 0) { _sName = _sWindowsName.Substring(0, index) + "_" + alternateSortName; } else { _sName = _sWindowsName; } _sRealName = _sName; _iLanguage = this.ILANGUAGE; if (_iLanguage == 0) { _iLanguage = CultureInfo.LOCALE_CUSTOM_UNSPECIFIED; } _bNeutral = (this.SISO3166CTRYNAME.Length == 0); _sSpecificCulture = _bNeutral ? LocaleData.GetSpecificCultureName(_sRealName) : _sRealName; // Remove the sort from sName unless custom culture if (index > 0 && !_bNeutral && !IsCustomCultureId(_iLanguage)) { _sName = _sWindowsName.Substring(0, index); } return(true); }
/// <summary> /// This method uses the sRealName field (which is initialized by the constructor before this is called) to /// initialize the rest of the state of CultureData based on the underlying OS globalization library. /// </summary> private unsafe bool InitCultureData() { Debug.Assert(_sRealName != null); Debug.Assert(!GlobalizationMode.Invariant); string realNameBuffer = _sRealName; // Basic validation if (realNameBuffer.Contains('@')) { return(false); // don't allow ICU variants to come in directly } // Replace _ (alternate sort) with @collation= for ICU ReadOnlySpan <char> alternateSortName = default; int index = realNameBuffer.IndexOf('_'); if (index > 0) { if (index >= (realNameBuffer.Length - 1) || // must have characters after _ realNameBuffer.IndexOf('_', index + 1) >= 0) // only one _ allowed { return(false); // fail } alternateSortName = realNameBuffer.AsSpan(index + 1); realNameBuffer = string.Concat(realNameBuffer.AsSpan(0, index), ICU_COLLATION_KEYWORD, alternateSortName); } // Get the locale name from ICU if (!GetLocaleName(realNameBuffer, out _sWindowsName)) { return(false); // fail } // Replace the ICU collation keyword with an _ Debug.Assert(_sWindowsName != null); index = _sWindowsName.IndexOf(ICU_COLLATION_KEYWORD, StringComparison.Ordinal); if (index >= 0) { _sName = string.Concat(_sWindowsName.AsSpan(0, index), "_", alternateSortName); } else { _sName = _sWindowsName; } _sRealName = _sName; _iLanguage = LCID; if (_iLanguage == 0) { _iLanguage = CultureInfo.LOCALE_CUSTOM_UNSPECIFIED; } _bNeutral = TwoLetterISOCountryName.Length == 0; _sSpecificCulture = _bNeutral ? LocaleData.GetSpecificCultureName(_sRealName) : _sRealName; // Remove the sort from sName unless custom culture if (index > 0 && !_bNeutral && !IsCustomCultureId(_iLanguage)) { _sName = _sWindowsName.Substring(0, index); } return(true); }
private static string LCIDToLocaleName(int culture) { return(LocaleData.LCIDToLocaleName(culture)); }
private void GenerateTargetLanguageList(int ContentLanguage) { Ektron.Cms.Common.Criteria<LocaleProperty> criteria = new Ektron.Cms.Common.Criteria<LocaleProperty>( LocaleProperty.EnglishName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending); criteria.PagingInfo.RecordsPerPage = Int32.MaxValue; criteria.AddFilter(LocaleProperty.Enabled, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, true); List<LocaleData> locales = _locApi.GetList(criteria); List<LocaleData> displayLocales = new List<LocaleData>(); if (m_intId > 0 && (CmsTranslatableType.Content == m_Type || CmsTranslatableType.Product == m_Type) ) { LocalizableCmsObjectType locObjType = LocalizableCmsObjectType.Content; switch (content_data.Type) { case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.Content: locObjType = LocalizableCmsObjectType.Content; break; case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.CatalogEntry: locObjType = LocalizableCmsObjectType.Product; break; default: locObjType = LocalizableCmsObjectType.DmsAsset; break; } List<LocalizationObjectData> localeObjectData = new List<LocalizationObjectData>(); Ektron.Cms.Framework.Localization.LocalizationObject localizationObject = new Ektron.Cms.Framework.Localization.LocalizationObject(); localeObjectData = localizationObject.GetLocalizationObjectList(locObjType, m_intId, -1); List<LocaleData> preselectedLocales = new List<LocaleData>(); locales.ForEach(delegate(LocaleData loc) { LanguageState enabled = (localeObjectData.FindAll(x => x.ObjectLanguage == loc.Id).Count > 0 ? LanguageState.Active : LanguageState.Undefined); LocaleData uiDisplayLocale = new LocaleData(loc.Id, loc.LCID, loc.EnglishName, loc.NativeName, loc.IsRightToLeft, loc.Loc, loc.Culture, loc.UICulture, loc.LangCode, loc.XmlLang, loc.FlagFile, loc.FlagUrl, loc.FallbackId, enabled); displayLocales.Add(uiDisplayLocale); }); } else { displayLocales = locales; } BoundField field = default(BoundField); LanguageGrid.Columns.Clear(); // Selected? field = new BoundField(); field.DataField = ""; //.HeaderText = "Export" field.HeaderText = "<input type=\"checkbox\" name=\"chkAll\" onclick=\"onCheckAll(this)\" checked=\"checked\" />"; field.HtmlEncode = false; field.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; field.HeaderStyle.Width = new Unit(20, UnitType.Pixel); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Center; LanguageGrid.Columns.Add(field); // Flag Icon field = new BoundField(); field.DataField = "FlagFile"; field.HeaderText = ""; field.HeaderStyle.Width = new Unit(20, UnitType.Pixel); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Center; LanguageGrid.Columns.Add(field); // Language Name field = new BoundField(); field.DataField = "CombinedName"; field.HtmlEncode = false; field.SortExpression = LocaleProperty.EnglishName.ToString(); field.HeaderText = GetMessage("generic name"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; field.ItemStyle.Wrap = false; LanguageGrid.Columns.Add(field); // Loc field = new BoundField(); field.DataField = "Loc"; field.SortExpression = LocaleProperty.Loc.ToString(); field.HeaderText = GetMessage("lbl loc"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; field.HeaderStyle.Width = new Unit(6, UnitType.Em); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Left; LanguageGrid.Columns.Add(field); //// Language Code //field = new BoundField(); //field.DataField = "XmlLang"; //// or "BrowserCode" //field.SortExpression = EkDS.SortBy.XmlLang.ToString(); //// or .BrowserCode //field.HeaderText = GetMessage("lbl code"); //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; //field.HeaderStyle.Width = new Unit(6, UnitType.Em); //field.ItemStyle.Wrap = false; //field.ItemStyle.HorizontalAlign = HorizontalAlign.Left; //LanguageGrid.Columns.Add(field); // Language ID (decimal) field = new BoundField(); field.DataField = "Id"; field.SortExpression = LocaleProperty.Id.ToString(); field.HeaderText = GetMessage("generic ID"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; field.HeaderStyle.CssClass = "right"; field.HeaderStyle.Width = new Unit(8, UnitType.Em); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; field.ItemStyle.CssClass = "right"; LanguageGrid.Columns.Add(field); //// Language ID (hex) //field = new BoundField(); //field.DataField = "LanguageID"; //field.HtmlEncode = false; //// necessary to make DataFormatString effective //field.DataFormatString = "{0:x4}"; //field.HeaderText = GetMessage("lbl hex"); //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; //field.HeaderStyle.Width = new Unit(4, UnitType.Em); //field.ItemStyle.Wrap = false; //field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; //LanguageGrid.Columns.Add(field); // FireFox: border between cells is a result of the <table rules="all" attribute, which I do not know how to eliminate. LanguageGrid.RowDataBound += LanguageGrid_RowDataBound; LanguageGrid.DataSource = displayLocales; LanguageGrid.DataBind(); }
public void InitSync() { _staticData = StaticData.Factory(); _userData = UserData.Factory(); _localeData = LocaleData.Factory(_userData.locale); }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new LocaleData(Row, this); break; } case 2: { Data = new GlobalData(Row, this); break; } case 3: { Data = new BillingPackageData(Row, this); break; } case 4: { Data = new AchievementData(Row, this); break; } case 5: { Data = new Data(Row, this); break; } case 6: { Data = new SoundData(Row, this); break; } case 7: { Data = new EffectData(Row, this); break; } case 8: { Data = new ParticleEmitterData(Row, this); break; } case 9: { Data = new ResourceData(Row, this); break; } case 10: { Data = new PuzzleData(Row, this); break; } case 11: { Data = new BlockData(Row, this); break; } case 12: { Data = new MonsterData(Row, this); break; } case 14: { Data = new LevelData(Row, this); break; } case 15: { Data = new TutorialData(Row, this); break; } case 16: { Data = new HeroData(Row, this); break; } case 17: { Data = new BoostData(Row, this); break; } case 18: { Data = new AttackTypeData(Row, this); break; } case 19: { Data = new SpecialMoveData(Row, this); break; } case 20: { Data = new PlaylistData(Row, this); break; } case 21: { Data = new ProjectileData(Row, this); break; } case 22: { Data = new MatchPatternData(Row, this); break; } case 23: { Data = new FacebookErrorData(Row, this); break; } case 24: { Data = new GateData(Row, this); break; } default: { Data = new Data(Row, this); break; } } return(Data); }
public void TestExemplarSet2() { int equalCount = 0; HashedSet testedExemplars = new HashedSet(); for (int i = 0; i < availableLocales.Length; i++) { ULocale locale = availableLocales[i]; LocaleData ld = IBM.ICU.Util.LocaleData.GetInstance(locale); int[] scriptCodes = IBM.ICU.Lang.UScript.GetCode(locale); if (scriptCodes == null) { if (locale.ToString().IndexOf(("in")) < 0) { Errln("UScript.getCode returned null for locale: " + locale); } continue; } UnicodeSet[] exemplarSets = new UnicodeSet[4]; for (int k = 0; k < 2; ++k) { // for casing option in (normal, // uncased) int option = (k == 0) ? 0 : IBM.ICU.Text.UnicodeSet.CASE; for (int h = 0; h < 2; ++h) { int type = (h == 0) ? IBM.ICU.Util.LocaleData.ES_STANDARD : IBM.ICU.Util.LocaleData.ES_AUXILIARY; UnicodeSet exemplarSet = ld.GetExemplarSet(option, type); exemplarSets[k * 2 + h] = exemplarSet; LocaleDataTest.ExemplarGroup exGrp = new LocaleDataTest.ExemplarGroup(exemplarSet, scriptCodes); if (!ILOG.J2CsMapping.Collections.Collections.Contains(exGrp, testedExemplars)) { ILOG.J2CsMapping.Collections.Generics.Collections.Add(testedExemplars, exGrp); UnicodeSet[] sets = new UnicodeSet[scriptCodes.Length]; // create the UnicodeSets for the script for (int j = 0; j < scriptCodes.Length; j++) { sets[j] = new UnicodeSet("[:" + IBM.ICU.Lang.UScript.GetShortName(scriptCodes[j]) + ":]"); } bool existsInScript = false; UnicodeSetIterator iter = new UnicodeSetIterator( exemplarSet); // iterate over the while (!existsInScript && iter.NextRange()) { if (iter.codepoint != IBM.ICU.Text.UnicodeSetIterator.IS_STRING) { for (int j_0 = 0; j_0 < sets.Length; j_0++) { if (sets[j_0].Contains(iter.codepoint, iter.codepointEnd)) { existsInScript = true; break; } } } else { for (int j_1 = 0; j_1 < sets.Length; j_1++) { if (sets[j_1].Contains(iter.str0)) { existsInScript = true; break; } } } } // TODO: How to verify LocaleData.ES_AUXILIARY ??? if (existsInScript == false && h == 0) { Errln("ExemplarSet containment failed for locale,option,type : " + locale + ", " + option + ", " + type); } } } } // This is expensive, so only do it if it will be visible if (IsVerbose()) { Logln(locale.ToString() + " exemplar(ES_STANDARD)" + exemplarSets[0]); Logln(locale.ToString() + " exemplar(ES_AUXILIARY) " + exemplarSets[1]); Logln(locale.ToString() + " exemplar(case-folded,ES_STANDARD) " + exemplarSets[2]); Logln(locale.ToString() + " exemplar(case-folded,ES_AUXILIARY) " + exemplarSets[3]); } AssertTrue(locale.ToString() + " case-folded is a superset", exemplarSets[2].ContainsAll(exemplarSets[0])); AssertTrue(locale.ToString() + " case-folded is a superset", exemplarSets[3].ContainsAll(exemplarSets[1])); if (exemplarSets[2].Equals(exemplarSets[0])) { ++equalCount; } if (exemplarSets[3].Equals(exemplarSets[1])) { ++equalCount; } } // Note: The case-folded set should sometimes be a strict superset // and sometimes be equal. AssertTrue( "case-folded is sometimes a strict superset, and sometimes equal", equalCount > 0 && equalCount < availableLocales.Length * 2); }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new BuildingData(Row, this); break; } case 2: { Data = new LocaleData(Row, this); break; } case 3: { Data = new ResourceData(Row, this); break; } case 4: { Data = new CharacterData(Row, this); break; } case 6: { Data = new ProjectileData(Row, this); break; } case 7: { Data = new BuildingClassData(Row, this); break; } case 8: { Data = new ObstacleData(Row, this); break; } case 9: { Data = new EffectData(Row, this); break; } case 10: { Data = new ParticleEmitterData(Row, this); break; } case 11: { Data = new ExperienceLevelData(Row, this); break; } case 12: { Data = new TrapData(Row, this); break; } case 13: { Data = new AllianceBadgeData(Row, this); break; } case 14: { Data = new GlobalData(Row, this); break; } case 15: { Data = new TownhallLevelData(Row, this); break; } case 16: { Data = new AlliancePortalData(Row, this); break; } case 17: { Data = new NpcData(Row, this); break; } case 18: { Data = new DecoData(Row, this); break; } case 19: { Data = new ResourcePackData(Row, this); break; } case 20: { Data = new ShieldData(Row, this); break; } case 21: { Data = new MissionData(Row, this); break; } case 22: { Data = new BillingPackageData(Row, this); break; } case 23: { Data = new AchievementData(Row, this); break; } case 25: { Data = new FaqData(Row, this); break; } case 26: { Data = new SpellData(Row, this); break; } case 27: { Data = new HintData(Row, this); break; } case 28: { Data = new HeroData(Row, this); break; } case 29: { Data = new LeagueData(Row, this); break; } case 30: { Data = new NewData(Row, this); break; } case 34: { Data = new AllianceBadgeLayerData(Row, this); break; } case 37: { Data = new VariableData(Row, this); break; } case 38: { Data = new GemBundleData(Row, this); break; } case 39: { Data = new VillageObjectData(Row, this); break; } default: { Data = new Data(Row, this); break; } } return(Data); }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new LocaleData(Row, this); break; } case 2: { Data = new BillingPackageData(Row, this); break; } case 3: case 20: { Data = new GlobalData(Row, this); break; } case 4: { Data = new SoundData(Row, this); break; } case 5: { Data = new ResourceData(Row, this); break; } case 9: { Data = new CharacterBuffData(Row, this); break; } case 10: { Data = new ProjectileData(Row, this); break; } case 11: { Data = new EffectData(Row, this); break; } case 12: { Data = new PredefinedDeckData(Row, this); break; } case 14: { Data = new RarityData(Row, this); break; } case 15: { Data = new LocationData(Row, this); break; } case 16: { Data = new AllianceBadgeData(Row, this); break; } case 18: { Data = new NpcData(Row, this); break; } case 19: { Data = new TreasureChestData(Row, this); break; } case 21: { Data = new ParticleEmitterData(Row, this); break; } case 22: { Data = new AreaEffectObjectData(Row, this); break; } case 26: case 27: case 28: case 29: { Data = new SpellData(Row, this); break; } case 34: case 35: { Data = new CharacterData(Row, this); break; } case 40: { Data = new HealthBarData(Row, this); break; } case 41: { Data = new MusicData(Row, this); break; } case 42: { Data = new DecoData(Row, this); break; } case 43: { Data = new GambleChestData(Row, this); break; } case 45: case 48: { Data = new TutorialData(Row, this); break; } case 46: { Data = new ExpLevelData(Row, this); break; } case 50: { Data = new BackgroundDecoData(Row, this); break; } case 51: { Data = new SpellSetData(Row, this); break; } case 52: { Data = new ChestOrderData(Row, this); break; } case 53: { Data = new TauntData(Row, this); break; } case 54: { Data = new ArenaData(Row, this); break; } case 55: { Data = new ResourcePackData(Row, this); break; } case 56: { Data = new Data(Row, this); break; } case 57: { Data = new RegionData(Row, this); break; } case 58: { Data = new NewsData(Row, this); break; } case 59: { Data = new AllianceRoleData(Row, this); break; } case 60: { Data = new AchievementData(Row, this); break; } case 61: { Data = new HintData(Row, this); break; } case 62: { Data = new HelpshiftData(Row, this); break; } default: { Logging.Info(this.GetType(), "Invalid data table id: " + this.Index + "."); Data = null; break; } } return(Data); }
private static int LocaleNameToLCID(string cultureName) { int lcid = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.Lcid); return(lcid == -1 ? CultureInfo.LOCALE_CUSTOM_UNSPECIFIED : lcid); }
public string LocalisedName(INamed obj, CultureInfo cultureInfo) { if (cultureInfo == null) { cultureInfo = CultureInfo.CurrentUICulture; } var cultureList = new[] { cultureInfo.Name, cultureInfo.Name.Split('/')[0], cultureInfo.TwoLetterISOLanguageName, "en" }; LocalisedString str = obj.LocalisedName; if (str == null) { var typeName = TypeNameConversions.TryGetValue(obj.Type, out var newType) ? newType : obj.Type; str = new LocalisedString { Format = $"{typeName}-name.{obj.Name}" }; } string GetString(string key) { foreach (var dict in cultureList) { if (LocaleData.TryGetValue(dict, out var dic)) { var val = ((JObject)dic).SelectToken(key); if (val != null) { return(val.Value <string>()); } } } return(null); } var fmt = GetString(str.Format); if (fmt == null && obj is IAltNames anames) { var altName = anames.AlternativeNames.Select(x => LocalisedName(new AltNameWrapper(x), cultureInfo)).FirstOrDefault(x => x != null); if (altName != null) { return(altName); } } if (fmt == null) { return(str.Format); } if (str.Arguments == null) { return(fmt); } return(FormattingRegex.Replace(fmt, (m) => { if (str.Arguments.TryGetValue((1 + int.Parse(m.Groups["num"].Value)).ToString(), out var arg)) { return GetString(((JObject)arg)["1"].Value <string>()); } return m.Value; })); }
private static string GetThreeLetterWindowsLanguageName(string cultureName) { return(LocaleData.GetThreeLetterWindowsLanguageName(cultureName) ?? "ZZZ" /* default lang name */); }
public void SaveStrings(List <LocalizedString> locales, IStream stream) { if (LocaleData == null || LocaleIndexTable == null) { return; } var offsetData = new MemoryStream(); var stringData = new MemoryStream(); var offsetWriter = new EndianWriter(offsetData, Endian.BigEndian); var stringWriter = new EndianWriter(stringData, Endian.BigEndian); try { // Write the string and offset data to buffers foreach (LocalizedString locale in locales) { WriteLocalePointer(offsetWriter, locale.Key, (int)stringWriter.Position); stringWriter.WriteUTF8(locale.Value); } // Round the size of the string data up var dataSize = (int)((stringData.Position + _sizeAlign - 1) & ~(_sizeAlign - 1)); stringData.SetLength(dataSize); // Update the two locale data hashes if we need to // (the hash arrays are set to null if the build doesn't need them) if (IndexTableHash != null) { IndexTableHash = SHA1.Transform(offsetData.GetBuffer(), 0, (int)offsetData.Length); } if (StringDataHash != null) { StringDataHash = SHA1.Transform(stringData.GetBuffer(), 0, dataSize); } // Make sure there's free space for the offset table and then write it to the file LocaleIndexTable.Resize((int)offsetData.Length, stream); stream.SeekTo(LocaleIndexTableLocation.AsOffset()); stream.WriteBlock(offsetData.GetBuffer(), 0, (int)offsetData.Length); // Encrypt the string data if necessary byte[] strings = stringData.GetBuffer(); if (_encryptionKey != null) { strings = AES.Encrypt(strings, 0, dataSize, _encryptionKey.Key, _encryptionKey.IV); } // Make sure there's free space for the string data and then write it to the file LocaleData.Resize(dataSize, stream); stream.SeekTo(LocaleDataLocation.AsOffset()); stream.WriteBlock(strings, 0, dataSize); // Update the string count and recalculate the language table offsets StringCount = locales.Count; } finally { offsetWriter.Close(); stringWriter.Close(); } }
private static string LCIDToLocaleName(int culture) { Debug.Assert(!GlobalizationMode.Invariant); return(LocaleData.LCIDToLocaleName(culture)); }
/// <summary> /// Decodes the <see cref="Message" />, using the <see cref="Reader" /> instance. /// </summary> internal override void Decode() { this.HighID = this.Reader.ReadInt32(); this.LowID = this.Reader.ReadInt32(); this.PassToken = this.Reader.ReadString(); this.MajorVersion = this.Reader.ReadInt32(); this.MinorVersion = this.Reader.ReadInt32(); this.BuildVersion = this.Reader.ReadInt32(); this.MasterHash = this.Reader.ReadString(); this.Reader.ReadString(); this.Device.Info.UDID = this.Reader.ReadString(); this.Device.Info.OpenUDID = this.Reader.ReadString(); this.Device.Info.DeviceModel = this.Reader.ReadString(); if (!this.Reader.EndOfStream) { this.LocaleData = this.Reader.ReadData <LocaleData>(); this.Device.Info.PreferredLanguageId = this.Reader.ReadString(); if (!this.Reader.EndOfStream) { this.Device.Info.ADID = this.Reader.ReadString(); if (!this.Reader.EndOfStream) { this.Device.Info.OSVersion = this.Reader.ReadString(); if (!this.Reader.EndOfStream) { this.Device.Info.Android = this.Reader.ReadBoolean(); if (!this.Reader.EndOfStream) { this.Reader.ReadString(); // Never null this.Reader.ReadString(); // Never null if (!this.Reader.EndOfStream) { this.Reader.ReadString(); // Never null if (!this.Reader.EndOfStream) { this.Device.Info.Advertising = this.Reader.ReadBoolean(); this.Reader.ReadString(); if (!this.Reader.EndOfStream) { this.Seed = this.Reader.ReadInt32(); if (!this.Reader.EndOfStream) { this.Reader.ReadVInt(); // AppStore this.Reader.ReadString(); // Never null, probably KunlunSSO this.Reader.ReadString(); // Never null, probably KunlunUID if (!this.Reader.EndOfStream) { this.GameVersion = this.Reader.ReadString(); // Never null if (!this.Reader.EndOfStream) { this.Reader.ReadString(); // Never null this.Reader.ReadString(); // Never null this.Reader.ReadVInt(); // Unknown } } } } } } } } } } } }
private static int GetOemCodePage(string cultureName) { int oemCodePage = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.OemCodePage); return(oemCodePage == -1 ? CultureData.Invariant.IDEFAULTOEMCODEPAGE : oemCodePage); }
internal Data Create(Row _Row) { Data _Data; switch ((Gamefile)this.Index) { case Gamefile.Buildings: _Data = new BuildingData(_Row, this); break; case Gamefile.Locales: _Data = new LocaleData(_Row, this); break; case Gamefile.Resources: _Data = new ResourceData(_Row, this); break; case Gamefile.Characters: _Data = new CharacterData(_Row, this); break; case Gamefile.Building_Classes: _Data = new BuildingClassData(_Row, this); break; case Gamefile.Obstacles: _Data = new ObstacleData(_Row, this); break; case Gamefile.Traps: _Data = new TrapData(_Row, this); break; case Gamefile.Globals: _Data = new GlobalData(_Row, this); break; case Gamefile.Experience_Levels: _Data = new ExperienceLevelData(_Row, this); break; case Gamefile.Townhall_Levels: _Data = new TownhallLevelData(_Row, this); break; case Gamefile.Npcs: _Data = new NpcData(_Row, this); break; case Gamefile.Decos: _Data = new DecoData(_Row, this); break; case Gamefile.Shields: _Data = new ShieldData(_Row, this); break; case Gamefile.Missions: _Data = new MissionData(_Row, this); break; case Gamefile.Achievements: _Data = new AchievementData(_Row, this); break; case Gamefile.Spells: _Data = new SpellData(_Row, this); break; case Gamefile.Heroes: _Data = new HeroData(_Row, this); break; case Gamefile.Leagues: _Data = new LeagueData(_Row, this); break; case Gamefile.Regions: _Data = new RegionData(_Row, this); break; case Gamefile.AllianceBadgeLayer: _Data = new AllianceBadgeLayerData(_Row, this); break; case Gamefile.Variables: _Data = new VariableData(_Row, this); break; case Gamefile.Village_Objects: _Data = new VillageObjectData(_Row, this); break; default: _Data = new Data(_Row, this); break; } return(_Data); }
private static int GetEbcdicCodePage(string cultureName) { int ebcdicCodePage = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.EbcdicCodePage); return(ebcdicCodePage == -1 ? CultureData.Invariant.IDEFAULTEBCDICCODEPAGE : ebcdicCodePage); }
/// <summary> /// Creates the data for the specified row. /// </summary> /// <param name="Row">The row.</param> internal Data Create(Row Row) { Data Data; switch (this.Index) { case 1: { Data = new LocaleData(Row, this); break; } case 2: { Data = new ResourceData(Row, this); break; } case 3: { Data = new EffectData(Row, this); break; } case 4: { Data = new ParticleEmitterData(Row, this); break; } case 5: { Data = new GlobalData(Row, this); break; } case 6: { Data = new QuestData(Row, this); break; } case 10: { Data = new WorldData(Row, this); break; } case 11: { Data = new HeroData(Row, this); break; } case 24: { Data = new TauntData(Row, this); break; } case 25: { Data = new DecoData(Row, this); break; } case 26: { Data = new VariableData(Row, this); break; } case 32: { Data = new EnergyPackageData(Row, this); break; } default: { Data = new Data(Row, this); break; } } return(Data); }
private static int GetDigitSubstitution(string cultureName) { int digitSubstitution = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.DigitSubstitution); return(digitSubstitution == -1 ? (int)DigitShapes.None : digitSubstitution); }
// ReSharper restore UseObjectOrCollectionInitializer // ReSharper restore FunctionNeverReturns protected static void Initialize() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); //mono hack CaseInsensitiveViewEngine.Register(ViewEngines.Engines); StructureMapIoC.CreateContainer(); ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(IocContainer.Instance)); ILocaleProvider localeProvider = IocContainer.Instance.Resolve<ILocaleProvider>(); LocaleData defaultLocale = new LocaleData { Culture = CultureInfo.GetCultureInfo("en"), FullName = "English", ShortName = "en" }; LocaleData russianLocale = new LocaleData { Culture = CultureInfo.GetCultureInfo("ru"), FullName = "Русский", ShortName = "ru" }; localeProvider.Init(new[] { defaultLocale, russianLocale }, defaultLocale); var timeZoneProvider = IocContainer.Instance.Resolve<ITimeZonesProvider>(); timeZoneProvider.Init(TimeZonesResources.ResourceManager); var iconProvider = IocContainer.Instance.Resolve<IIconProvider>(); iconProvider.Initizlize(); var oldValidatorProvider = ModelValidatorProviders.Providers.Single(p => p is DataAnnotationsModelValidatorProvider); ModelValidatorProviders.Providers.Remove(oldValidatorProvider); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; ModelValidatorProviders.Providers.Add(new DataAnnotationsModelValidatorProvider()); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MinPasswordLengthAttribute), typeof(MinPasswordLengthValidator)); DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(PropertiesMustMatchAttribute), typeof(PropertiesMustMatchValidator)); }
private static string GetConsoleFallbackName(string cultureName) { return(LocaleData.GetConsoleUICulture(cultureName)); }
protected void Initialize() { AreaRegistration.RegisterAllAreas(); IoCcontainer.ConfigureStructureMap(ConfigurationManager.AppSettings["iocConfigFile"]); ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(IoCcontainer.Instance)); ILocaleProvider localeProvider = IoCcontainer.Instance.Resolve<ILocaleProvider>(); LocaleData defaultLocale = new LocaleData { Culture = CultureInfo.GetCultureInfo("en"), FullName = "English", ShortName = "en" }; LocaleData russianLocale = new LocaleData { Culture = CultureInfo.GetCultureInfo("ru"), FullName = "Русский", ShortName = "ru" }; localeProvider.Init(new[] { defaultLocale, russianLocale }, defaultLocale); RegisterRoutes(RouteTable.Routes); DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(MinStringLengthAttribute), typeof(MinStringLengthValidator)); DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(PropertiesMustMatchAttribute), typeof(PropertiesMustMatchValidator)); }