GetText() public method

Get the text for the symbol to use in text descriptions.
public GetText ( string language ) : string
language string The language to use.
return string
Ejemplo n.º 1
0
        // Get the text for a symbol. Checks the eventDB for overrides to the symbol text; otherwise uses the default for the symbol.
        string GetSymbolText(Symbol symbol, string gender, string nounCase = "")
        {
            Event  ev = eventDB.GetEvent();
            string id = symbol.Id;

            if (ev.customSymbolText.ContainsKey(id) && Symbol.ContainsLanguage(ev.customSymbolText[id], language))
            {
                return(Symbol.GetBestSymbolText(symbolDB, ev.customSymbolText[id], language, false, gender, nounCase));
            }
            else
            {
                return(symbol.GetText(language, gender, nounCase));
            }
        }
Ejemplo n.º 2
0
        public string CreateTextForDirective(string symbolId, string distanceText)
        {
            if (symbolId == null)
            {
                return(null);        // no text available.
            }
            Symbol symbol = symbolDB[symbolId];

            // Always need to add a space suffix unless it is empty..
            if (distanceText != "")
            {
                distanceText = distanceText + " ";
            }
            return(CapitalizeFirstLetter(string.Format(symbol.GetText(language), distanceText)));  // Note: directive texts cant be customized, so we don't use GetSymbolText here.
        }
Ejemplo n.º 3
0
 // Create a combination string for crossing/junction/between.
 string CombineSymbols(Symbol comboSymbol, string mainFeature, string mainFeaturePlural, string secondaryFeature, out string pluralCombo, out string gender)
 {
     pluralCombo = null;
     if (secondaryFeature == null && mainFeaturePlural != null)
     {
         Symbol singleComboSymbol = GetSingleVersionOfComboSymbol(comboSymbol);
         pluralCombo = string.Format(singleComboSymbol.GetPluralText(language), mainFeature, mainFeaturePlural);
         gender      = singleComboSymbol.GetGender(language);
         return(string.Format(singleComboSymbol.GetText(language), mainFeature, mainFeaturePlural));
     }
     else
     {
         pluralCombo = string.Format(comboSymbol.GetPluralText(language), mainFeature, secondaryFeature == null ? mainFeature : secondaryFeature);
         gender      = comboSymbol.GetGender(language);
         return(string.Format(comboSymbol.GetText(language), mainFeature, secondaryFeature == null ? mainFeature : secondaryFeature));
     }
 }
Ejemplo n.º 4
0
        string GetTextFromSize(string size, bool useDeepOrHigh, bool firstIsDeep, string genderFirst, bool secondIsDeep, string genderSecond, out Symbol symbolControllingNounCase)
        {
            symbolControllingNounCase = null;

            // If it's a combo, figure out which kind and the correct combining word.
            Symbol combiner = null;
            int    index    = size.IndexOf('|');

            if (index >= 0)
            {
                combiner = symbolDB["9.4"];
            }
            else
            {
                index = size.IndexOf('/');
                if (index >= 0)
                {
                    combiner = firstIsDeep ? symbolDB["9.3deep"] : symbolDB["9.3high"];
                    symbolControllingNounCase = combiner;
                    useDeepOrHigh             = false;
                }
                else
                {
                    index = size.IndexOf('x');
                    if (index >= 0)
                    {
                        combiner = symbolDB["9.2"];
                        symbolControllingNounCase = combiner;
                        useDeepOrHigh             = false;
                    }
                }
            }

            if (combiner != null)
            {
                // Combo string
                Symbol firstSymbolControllingNounCase;
                string firstText  = GetTextFromSize(size.Substring(0, index), useDeepOrHigh, firstIsDeep, genderFirst, firstIsDeep, genderFirst, out firstSymbolControllingNounCase);
                string secondText = GetTextFromSize(size.Substring(index + 1), useDeepOrHigh, secondIsDeep, genderSecond, secondIsDeep, genderSecond);
                if (string.IsNullOrEmpty(firstText) || string.IsNullOrEmpty(secondText))
                {
                    return(size);
                }
                else
                {
                    if (symbolControllingNounCase == null)
                    {
                        symbolControllingNounCase = firstSymbolControllingNounCase;
                    }

                    return(string.Format(combiner.GetText(language, genderFirst), firstText, secondText));
                }
            }
            else
            {
                // Simple string.
                // Trim spaces and any "m" suffix.
                size = size.Trim();
                if (size.EndsWith("m", StringComparison.InvariantCulture))
                {
                    size = size.Substring(0, size.Length - 1);
                }

                // Convert to a double. Allow the current culture, US and french cultures (to allow either "." or "," as the decimal point.)
                double value;
                if (double.TryParse(size, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, null, out value) ||
                    double.TryParse(size, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.GetCultureInfo("en-US"), out value) ||
                    double.TryParse(size, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.GetCultureInfo("fr-FR"), out value))
                {
                    string text = Convert.ToString(value) + "m";
                    if (useDeepOrHigh)
                    {
                        Symbol symbol = firstIsDeep ? symbolDB["9.1deep"] : symbolDB["9.1high"];
                        symbolControllingNounCase = symbol;
                        return(string.Format(symbol.GetText(language, genderFirst), text));
                    }
                    else
                    {
                        return(text);
                    }
                }
                else
                {
                    return(size);
                }
            }
        }
Ejemplo n.º 5
0
        // Get the text for a symbol. Checks the eventDB for overrides to the symbol text; otherwise uses the default for the symbol.
        string GetSymbolText(Symbol symbol, string gender, string nounCase = "")
        {
            Event ev = eventDB.GetEvent();
            string id = symbol.Id;

            if (ev.customSymbolText.ContainsKey(id) && Symbol.ContainsLanguage(ev.customSymbolText[id], language))
                return Symbol.GetBestSymbolText(symbolDB, ev.customSymbolText[id], language, false, gender, nounCase);
            else
                return symbol.GetText(language, gender, nounCase);
        }
Ejemplo n.º 6
0
 // Create a combination string for crossing/junction/between.
 string CombineSymbols(Symbol comboSymbol, string mainFeature, string mainFeaturePlural, string secondaryFeature, out string pluralCombo, out string gender)
 {
     pluralCombo = null;
     if (secondaryFeature == null && mainFeaturePlural != null) {
         Symbol singleComboSymbol = GetSingleVersionOfComboSymbol(comboSymbol);
         pluralCombo = string.Format(singleComboSymbol.GetPluralText(language), mainFeature, mainFeaturePlural);
         gender = singleComboSymbol.GetGender(language);
         return string.Format(singleComboSymbol.GetText(language), mainFeature, mainFeaturePlural);
     }
     else {
         pluralCombo = string.Format(comboSymbol.GetPluralText(language), mainFeature, secondaryFeature == null ? mainFeature : secondaryFeature);
         gender = comboSymbol.GetGender(language);
         return string.Format(comboSymbol.GetText(language), mainFeature, secondaryFeature == null ? mainFeature : secondaryFeature);
     }
 }