public void TestLocalisableStringEqualsTranslatableString() { LocalisableString localisable = new TranslatableString(makeStringA, makeStringB, makeStringA, makeStringB); testEquals(true, localisable, new TranslatableString(makeStringA, makeStringB, makeStringA, makeStringB)); testEquals(false, localisable, new TranslatableString(makeStringB, makeStringA)); testEquals(false, localisable, makeStringA); testEquals(false, localisable, new RomanisableString(makeStringA, makeStringB)); }
public void TestTranslatableStringEqualsTranslatableString() { var str1 = new TranslatableString(makeStringA, makeStringB, makeStringA, makeStringB); var str2 = new TranslatableString(makeStringA, makeStringB); testEquals(true, str1, str1); testEquals(true, str1, new TranslatableString(makeStringA, makeStringB, makeStringA, makeStringB)); // Structural equality. testEquals(false, str1, str2); }
public void TestFormattedAndLocalisedUsingFormat() { var formattable = LocalisableString.Format("{0:0.00%}", 0.1234); var translatable1 = new TranslatableString(FakeStorage.LOCALISABLE_STRING_EN, FakeStorage.LOCALISABLE_STRING_EN); var translatable2 = new TranslatableString(FakeStorage.LOCALISABLE_FORMAT_STRING_EN, FakeStorage.LOCALISABLE_FORMAT_STRING_EN, formattable); manager.AddLanguage("ja", new FakeStorage("ja")); config.SetValue(FrameworkSetting.Locale, "ja"); var formattedText = manager.GetLocalisedBindableString(LocalisableString.Format("{0} -> {1}", translatable1, translatable2)); Assert.AreEqual("localised JA -> 12.34% localised JA", formattedText.Value); }
/// <summary> /// Gets the display name of the language. /// </summary> /// <param name="cultureInfo">The culture information.</param> /// <returns>The display name of the language.</returns> public static string GetLanguageDisplayName(CultureInfo cultureInfo) { var baseCultureInfo = cultureInfo; while (!string.IsNullOrEmpty(baseCultureInfo.Parent.Name)) { baseCultureInfo = baseCultureInfo.Parent; } // ReSharper disable LocalizableElement var language = new TranslatableString(string.Format(CultureInfo.InvariantCulture, @"LanguageName_{0}", baseCultureInfo.TwoLetterISOLanguageName), @"EH.ImsOpcBridge.Properties.Resources", Assembly.GetExecutingAssembly().FullName); // ReSharper restore LocalizableElement return(language.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="TaskItem" /> class. /// </summary> /// <param name="taskHandler">The task handler.</param> /// <param name="title">The title.</param> /// <param name="text">The translatable text.</param> /// <param name="countTotal">The count total.</param> /// <param name="countCurrent">The count current.</param> protected TaskItem(ITaskHandler taskHandler, TranslatableString title, TranslatableString text, int countTotal, int countCurrent) { if (taskHandler == null) { throw new ArgumentNullException(@"taskHandler"); } this.Status = AsyncOperationStatus.Idle; this.TaskHandler = taskHandler; this.ProgressTitle = title; this.ProgressItem = new ProgressItem(taskHandler.ProgressHandler, this, text, countTotal, countCurrent); this.ProgressItem.SetCancelDelegate(this.Cancel); this.ProgressItem.Canceled += this.HandleProgressItemCanceled; this.ProgressItem.Completed += this.HandleProgressItemCompleted; this.TaskHandler.Add(this); }
/// <summary> /// Initializes a new instance of the <see cref="ProgressItem" /> class. /// Constructor /// </summary> /// <param name="progressHandler">The progress handler.</param> /// <param name="progressProvider">The progress provider.</param> /// <param name="translatableText">The translatable text.</param> /// <param name="countTotal">The count total.</param> /// <param name="countCurrent">The count current.</param> public ProgressItem(IProgressHandler progressHandler, IProgressProvider progressProvider, TranslatableString translatableText, int countTotal, int countCurrent) { this.ProgressHandler = progressHandler; this.ProgressProvider = progressProvider; this.CountTotal = countTotal; this.CountCurrent = countCurrent; this.translatableText = translatableText; if (Logger.IsDebugEnabled) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.CreatingProgressItemTitle_Text_CountTotal_CountCurrent_, this.Title, translatableText, countTotal, countCurrent); Logger.Debug(message); } this.ProgressHandler.Add(this); }
/// <summary> /// Sets the text. /// </summary> /// <param name="text">The text.</param> public void SetText(ITranslatableString text) { if (!this.IsProgressActive) { // progress is not active anymore, don't change it return; } if (Logger.IsDebugEnabled) { var message = string.Format(CultureInfo.CurrentUICulture, Resources.SettingTextPropertyOfProgressItemWithTitle_To_, this.Title, text); Logger.Debug(message); } lock (this.textLock) { this.translatableText = new TranslatableString(text); this.OnChanged(); } }
private void onCurrentChanged(ValueChangedEvent <int> count) { Text = new TranslatableString(@"_", "{0} ({1})", CommonStrings.ButtonsShowMore.ToUpper(), count.NewValue); }
private void updateDisplay(APIUser user) { topLinkContainer.Clear(); bottomLinkContainer.Clear(); if (user == null) { return; } if (user.JoinDate.ToUniversalTime().Year < 2008) { topLinkContainer.AddText(UsersStrings.ShowFirstMembers); } else { topLinkContainer.AddText("Joined "); topLinkContainer.AddText(new DrawableDate(user.JoinDate, italic: false), embolden); } addSpacer(topLinkContainer); if (user.IsOnline) { topLinkContainer.AddText(UsersStrings.ShowLastvisitOnline); addSpacer(topLinkContainer); } else if (user.LastVisit.HasValue) { topLinkContainer.AddText("Last seen "); topLinkContainer.AddText(new DrawableDate(user.LastVisit.Value, italic: false), embolden); addSpacer(topLinkContainer); } if (user.PlayStyles?.Length > 0) { topLinkContainer.AddText("Plays with "); LocalisableString playStylesString = user.PlayStyles[0].GetLocalisableDescription(); for (int i = 1; i < user.PlayStyles.Length; i++) { playStylesString = new TranslatableString(@"_", @"{0}{1}", playStylesString, CommonStrings.ArrayAndWordsConnector); playStylesString = new TranslatableString(@"_", @"{0}{1}", playStylesString, user.PlayStyles[i].GetLocalisableDescription()); } topLinkContainer.AddText(playStylesString, embolden); addSpacer(topLinkContainer); } topLinkContainer.AddText("Contributed "); topLinkContainer.AddLink("forum post".ToQuantity(user.PostCount, "#,##0"), $"{api.WebsiteRootUrl}/users/{user.Id}/posts", creationParameters: embolden); addSpacer(topLinkContainer); topLinkContainer.AddText("Posted "); topLinkContainer.AddLink("comment".ToQuantity(user.CommentsCount, "#,##0"), $"{api.WebsiteRootUrl}/comments?user_id={user.Id}", creationParameters: embolden); string websiteWithoutProtocol = user.Website; if (!string.IsNullOrEmpty(websiteWithoutProtocol)) { if (Uri.TryCreate(websiteWithoutProtocol, UriKind.Absolute, out var uri)) { websiteWithoutProtocol = uri.Host + uri.PathAndQuery + uri.Fragment; websiteWithoutProtocol = websiteWithoutProtocol.TrimEnd('/'); } } bool anyInfoAdded = false; anyInfoAdded |= tryAddInfo(FontAwesome.Solid.MapMarker, user.Location); anyInfoAdded |= tryAddInfo(OsuIcon.Heart, user.Interests); anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation); if (anyInfoAdded) { bottomLinkContainer.NewLine(); } if (!string.IsNullOrEmpty(user.Twitter)) { anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}"); } anyInfoAdded |= tryAddInfo(FontAwesome.Brands.Discord, user.Discord); anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Link, websiteWithoutProtocol, user.Website); // If no information was added to the bottomLinkContainer, hide it to avoid unwanted padding bottomLinkContainer.Alpha = anyInfoAdded ? 1 : 0; }
public void SetRoomInfo(TranslatableString roomInfo_text_translatable) { text_translator.translatable_string = roomInfo_text_translatable; text_translator.TranslateString(); Debug.Log("SetRoomInfo"); }
public void SetRoomName(TranslatableString roomName_text_translatable) { roomName_translator.translatable_string = roomName_text_translatable; roomName_translator.TranslateString(); }
/// <summary> /// Initializes a new instance of the <see cref="ProgressProvider" /> class. /// </summary> /// <param name="title">The title.</param> /// <param name="context">The context.</param> public ProgressProvider(TranslatableString title, object context) { this.ProgressTitle = title; this.ProgressContext = context; }