/// <summary> /// Creates a new writing system. /// </summary> /// <param name="languageSubtag">The language subtag.</param> /// <param name="scriptSubtag">The script subtag.</param> /// <param name="regionSubtag">The region subtag.</param> /// <param name="variantSubtags">The variant subtags.</param> /// <returns></returns> public CoreWritingSystemDefinition Create(LanguageSubtag languageSubtag, ScriptSubtag scriptSubtag, RegionSubtag regionSubtag, IEnumerable <VariantSubtag> variantSubtags) { lock (m_syncRoot) { VariantSubtag[] variantSubtagsArray = variantSubtags.ToArray(); string langTag = IetfLanguageTag.Create(languageSubtag, scriptSubtag, regionSubtag, variantSubtagsArray); CoreWritingSystemDefinition ws; m_repo.WritingSystemFactory.Create(langTag, out ws); if (ws.Language != null && languageSubtag != null && ws.Language.Name != languageSubtag.Name) { ws.Language = new LanguageSubtag(ws.Language, languageSubtag.Name); } if (ws.Script != null && scriptSubtag != null && ws.Script.Name != scriptSubtag.Name) { ws.Script = new ScriptSubtag(ws.Script, scriptSubtag.Name); } if (ws.Region != null && regionSubtag != null && ws.Region.Name != regionSubtag.Name) { ws.Region = new RegionSubtag(ws.Region, regionSubtag.Name); } for (int i = 0; i < Math.Min(ws.Variants.Count, variantSubtagsArray.Length); i++) { if (ws.Variants[i].Code == variantSubtagsArray[i].Code && ws.Variants[i].Name != variantSubtagsArray[i].Name) { ws.Variants[i] = new VariantSubtag(ws.Variants[i], variantSubtagsArray[i].Name); } } if (ws.Language != null && !string.IsNullOrEmpty(ws.Language.Name)) { ws.Abbreviation = ws.Language.Name.Length > 3 ? ws.Language.Name.Substring(0, 3) : ws.Language.Name; } else { ws.Abbreviation = ws.LanguageTag; } if (ws.DefaultCollation == null) { string message; if (SystemCollator.ValidateLanguageTag(ws.LanguageTag, out message)) { ws.DefaultCollation = new SystemCollationDefinition { LanguageTag = ws.LanguageTag } } ; else { ws.DefaultCollation = new IcuRulesCollationDefinition("standard"); } } if (ws.DefaultFont == null) { ws.DefaultFont = new FontDefinition("Charis SIL"); } ws.AcceptChanges(); return(ws); } }
public void Compare_InvariantCultureKhmerStrings_AreNotSame() { string a = "សង្ឃនៃអំបូរអឺរ៉ុន"; string b = "បូជាចារ្យនៃអំបូរអឺរ៉ុន"; _collator = new SystemCollator(""); var order = _collator.Compare(a, b); Assert.That(order, Is.Not.EqualTo(0)); }
public void Compare_EnglishCultureEnglishStrings_AreNotSame() { string a = "an english sentence"; string b = "some words"; _collator = new SystemCollator("en"); var order = _collator.Compare(a, b); Assert.That(order, Is.Not.EqualTo(0)); }
public void Compare_EnglishCultureEnglishStrings_AreNotSame() { string a = "an english sentence"; string b = "some words"; _collator = new SystemCollator("en"); var order = _collator.Compare(a, b); Assert.That(order, Is.Not.EqualTo(0)); }
public void Compare_InvariantCultureKhmerStrings_AreNotSame() { string a = "សង្ឃនៃអំបូរអឺរ៉ុន"; string b = "បូជាចារ្យនៃអំបូរអឺរ៉ុន"; _collator = new SystemCollator(""); var order = _collator.Compare(a, b); Assert.That(order, Is.Not.EqualTo(0)); }
public override bool Validate(out string message) { if (IsValid) { message = null; return(true); } IsValid = SystemCollator.ValidateLanguageTag(_languageTag, out message); return(IsValid); }
public void English_ProducesCollator() { _collator = new SystemCollator("en"); Assert.IsNotNull(_collator); }
public void InvalidId_ProducesCollator() { _collator = new SystemCollator("This shouldn't be a valid culture ID."); Assert.IsNotNull(_collator); }
public void EmptyId_ProducesCollator() { _collator = new SystemCollator(String.Empty); Assert.IsNotNull(_collator); }
public void NullId_ProducesCollator() { _collator = new SystemCollator(null); Assert.IsNotNull(_collator); }
public void EmptyId_ProducesCollator() { _collator = new SystemCollator(String.Empty); Assert.IsNotNull(_collator); }
public void ValidateLanguageTag_InValid_ReturnsFalse() { string message; Assert.That(SystemCollator.ValidateLanguageTag("invalid", out message), Is.False); }
public void ValidateLanguageTag_Valid_ReturnsTrue() { string message; Assert.That(SystemCollator.ValidateLanguageTag("en-US", out message), Is.True); }
public void English_ProducesCollator() { _collator = new SystemCollator("en"); Assert.IsNotNull(_collator); }
public void InvalidId_ProducesCollator() { _collator = new SystemCollator("This shouldn't be a valid culture ID."); Assert.IsNotNull(_collator); }
public void ValidateLanguageTag_UserCustomCulture_ReturnsFalse() { string message; Assert.That(SystemCollator.ValidateLanguageTag("en-US-fonipa", out message), Is.False); }
public void NullId_ProducesCollator() { _collator = new SystemCollator(null); Assert.IsNotNull(_collator); }