private static void context_AfterItemAutoTranslation(object sender, AutoTranslationEventArgs<AutoTranslationResult> e) { // there is a problem with Microsoft translator and results have a space at the end, although original text does not // following code removes that obsolete character var translationResult = e.Item; if (translationResult.Text.EndsWith(" ", StringComparison.InvariantCultureIgnoreCase) && !translationResult.OriginalText.EndsWith(" ", StringComparison.InvariantCultureIgnoreCase)) { translationResult.Text = translationResult.Text.Substring(0, translationResult.Text.Length - 1); } }
private static void context_AfterItemAutoTranslation(object sender, AutoTranslationEventArgs <AutoTranslationResult> e) { // there is a problem with Microsoft translator and results have a space at the end, although original text does not // following code removes that obsolete character var translationResult = e.Item; if (translationResult.Text.EndsWith(" ", StringComparison.InvariantCultureIgnoreCase) && !translationResult.OriginalText.EndsWith(" ", StringComparison.InvariantCultureIgnoreCase)) { translationResult.Text = translationResult.Text.Substring(0, translationResult.Text.Length - 1); } }
/// <summary> /// Replaces placeholders - created by <see cref="context_BeforeItemAutoTranslation"/> - back to original texts /// </summary> private void context_AfterItemAutoTranslation(object sender, AutoTranslationEventArgs <AutoTranslationResult> e) { e.Item.Text = this.exclusionManager.Restore(e.Item.Text); }
/// <summary> /// Before translating an item, replace with placeholders all the texts that should not be exluded. /// the placeholders will be replaced back with the original text after the translation /// See <see cref="context_AfterItemAutoTranslation"/> /// </summary> private void context_BeforeItemAutoTranslation(object sender, AutoTranslationEventArgs <AutoTranslationItem> e) { // pass strings from exclusion manager to exclude items that should not be translated e.Item.Text = this.exclusionManager.Exclude(e.Item.Text); }
/// <summary> /// Before translating an item, replace with placeholders all the texts that should not be exluded. /// the placeholders will be replaced back with the original text after the translation /// See <see cref="context_AfterItemAutoTranslation"/> /// </summary> private void context_BeforeItemAutoTranslation(object sender, AutoTranslationEventArgs<AutoTranslationItem> e) { // pass strings from exclusion manager to exclude items that should not be translated e.Item.Text = this.exclusionManager.Exclude(e.Item.Text); }
/// <summary> /// Replaces placeholders - created by <see cref="context_BeforeItemAutoTranslation"/> - back to original texts /// </summary> private void context_AfterItemAutoTranslation(object sender, AutoTranslationEventArgs<AutoTranslationResult> e) { e.Item.Text = this.exclusionManager.Restore(e.Item.Text); }