コード例 #1
0
        /// <summary>
        /// Demonstrates how to store <see cref="Glossary"/> data in a <see cref="Unit"/> element.
        /// </summary>
        public static void StoreGlossary()
        {
            GlossaryEntry entry;
            MarkedSpan span;
            Segment segment;
            Translation translation;
            Unit unit;

            // Create a unit to hold the glossary.
            unit = new Unit("id");
            unit.Glossary = new Glossary();
            entry = new GlossaryEntry();
            entry.Reference = "#m1";
            unit.Glossary.Entries.Add(entry);

            // Create a term that looks like: <gls:term source="publicTermbase">TAB key</gls:term>
            entry.Term.Source = "publicTermbase";
            entry.Term.Text = "TAB key";

            // Create a translation that looks like: <gls:translation id="1" source="myTermbase">Tabstopptaste</gls:translation>
            translation = new Translation("1");
            translation.Source = "myTermbase";
            translation.Text = "Tabstopptaste";
            entry.Translations.Add(translation);

            // Create a translation that looks like: <gls:translation ref="#m2" source="myTermbase">TAB-TASTE</gls:translation>
            translation = new Translation();
            translation.Reference = "#m1";
            translation.Source = "myTermbase";
            translation.Text = "TAB-TASTE";
            entry.Translations.Add(translation);

            // Create a definition that looks like:
            //  <gls:definition source="publicTermbase">A keyboard key that is traditionally used to insert tab"
            //      characters into a document.</gls:definition>
            entry.Definition = new Definition();
            entry.Definition.Source = "publicTermbase";
            entry.Definition.Text = "A keyboard key that is traditionally used to insert tab characters into a document.";

            // Create a segment to which the glossary refers.
            segment = new Segment();
            segment.Source = new Source();
            segment.Source.Text.Add(new PlainText("Press the "));
            span = new MarkedSpan("m1");
            span.Type = "term";
            span.Text.Add(new PlainText("TAB key"));
            segment.Source.Text.Add(span);

            segment.Target = new Target();
            segment.Target.Text.Add(new PlainText("Drücken Sie die "));
            span = new MarkedSpan("m1");
            span.Type = "term";
            span.Text.Add(new PlainText("TAB-TASTE"));
            segment.Target.Text.Add(span);

            unit.Resources.Add(segment);
        }
コード例 #2
0
 public void TestInitialize()
 {
     this.element = new Translation();
     this.provider = this.element;
 }
コード例 #3
0
        public void GlossaryDefaultValue_Translation()
        {
            Translation translation;

            translation = new Translation("id");
            Assert.AreEqual("id", translation.Id, "Id is incorrect.");
            Assert.IsNull(translation.Reference, "Reference is incorrect.");
            Assert.IsNull(translation.Source, "Source is incorrect.");
            Assert.IsNull(translation.Text, "Text is incorrect.");
        }
コード例 #4
0
        /// <summary>
        /// Creates a glossary translation with every element and attribute.
        /// </summary>
        /// <param name="segmentId">The Id of the segment containing the glossary.</param>
        /// <returns>The created glossary translation.</returns>
        private Translation CreateGlossaryTranslation(string segmentId)
        {
            Translation result;

            result = new Translation();
            result.Id = "trans" + this.GetNextId(typeof(Translation));
            result.Reference = Utilities.MakeIri(segmentId);
            result.Source = "translationSource";
            result.Text = "translation text";

            return result;
        }