Ejemplo n.º 1
0
        /// <summary>
        /// This is the click handler for the 'Display' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // Text for which translation of the numeral system will be performed.  Please note that translation only happens between
            // Latin and any other supported numeral system.  Translation between numeral systems is not a supported scenario.
            String stringToTranslate = "These are the 10 digits of a numeral system: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";

            // Variable where we keep the results of the scenario
            StringBuilder results = new StringBuilder();

            results.Append("Original string: " + stringToTranslate + "\n\n");

            // The numeral system translator is initialized based on the current application language.
            NumeralSystemTranslator numeralTranslator = new Windows.Globalization.NumberFormatting.NumeralSystemTranslator();

            // Do translation
            results.Append("Using application settings (" + numeralTranslator.NumeralSystem + "): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Switch to a different numeral system
            numeralTranslator.NumeralSystem = "hanidec";

            // Do translation
            results.Append("Using numeral system via property (" + numeralTranslator.NumeralSystem + " ): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Create a converter using a language list to initialize the numeral system to an appropriate default
            numeralTranslator = new Windows.Globalization.NumberFormatting.NumeralSystemTranslator(new string[] { "ar-SA", "en-US" });

            // Do translation
            results.Append("Using numeral system via language list (" + numeralTranslator.NumeralSystem + "): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
        /// <summary>
        /// This is the click handler for the 'Display' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // Text for which translation of the numeral system will be performed.  Please note that translation only happens between
            // Latin and any other supported numeral system.  Translation between numeral systems is not a supported scenario.
            String stringToTranslate = "These are the 10 digits of a numeral system: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";

            // Variable where we keep the results of the scenario
            StringBuilder results = new StringBuilder();
            results.Append("Original string: " + stringToTranslate + "\n\n");

            // The numeral system translator is initialized based on the current application language.
            NumeralSystemTranslator numeralTranslator = new Windows.Globalization.NumberFormatting.NumeralSystemTranslator();

            // Do translation
            results.Append("Using application settings (" + numeralTranslator.NumeralSystem + "): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Switch to a different numeral system
            numeralTranslator.NumeralSystem = "hanidec";

            // Do translation
            results.Append("Using numeral system via property (" + numeralTranslator.NumeralSystem + " ): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Create a converter using a language list to initialize the numeral system to an appropriate default
            numeralTranslator = new Windows.Globalization.NumberFormatting.NumeralSystemTranslator(new string[] {"ar-SA", "en-US"}); 

            // Do translation
            results.Append("Using numeral system via language list (" + numeralTranslator.NumeralSystem + "): ");
            results.Append(numeralTranslator.TranslateNumerals(stringToTranslate) + "\n");

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
Ejemplo n.º 3
0
 public DecimalFormatter()
 {
     _formatterHelper = new FormatterHelper();
     _translator      = new NumeralSystemTranslator();
 }
Ejemplo n.º 4
0
 public PermilleFormatter()
 {
     _formatterHelper = new FormatterHelper();
     _translator      = new NumeralSystemTranslator();
 }