예제 #1
0
        /// <summary>
        /// An implementation of <see cref="TranslationController.GetStringWithDefault(StringNames, string, Il2CppReferenceArray{Il2CppSystem.Object})"/> that handles IL2CPP casting and default value when a translation does not exist.
        /// </summary>
        /// <param name="translationController">An instance of <see cref="TranslationController"/></param>
        /// <param name="str">String name to retrieve</param>
        /// <param name="defaultStr">Default string when translation is missing</param>
        /// <param name="parts">Elements to pass for formatting</param>
        /// <returns>The translated value of <paramref name="str"/> or <paramref name="defaultStr"/> when untranslated or when an instance of <see cref="TranslationController"/> does not exist or does not have an instance of <see cref="LanguageUnit"/> assigned to <see cref="TranslationController.CurrentLanguage"/> or <see cref="TranslationController.FallbackLanguage"/>.</returns>
        public static string GetStringWithDefault(this TranslationController translationController, StringNames str, string defaultStr, params object[] parts)
        {
            string text = translationController.GetString(str, parts);

            return /*str == StringNames.NoTranslation &&*/ (text.Equals("STRMISS", StringComparison.Ordinal) && !string.IsNullOrEmpty(defaultStr) ? string.Format(defaultStr, parts) : text);
        }
예제 #2
0
 public static string GetString(this TranslationController t, StringNames key, params Il2CppSystem.Object[] parts)
 {
     return(t.GetString(key, parts));
 }
예제 #3
0
 /// <summary>
 /// An implementation of <see cref="TranslationController.GetString(StringNames, Il2CppReferenceArray{Il2CppSystem.Object})"/> that handles IL2CPP casting (do not use on plugin load).
 /// </summary>
 /// <param name="translationController">An instance of <see cref="TranslationController"/></param>
 /// <param name="str">String name to retrieve</param>
 /// <param name="parts">Elements to pass for formatting</param>
 /// <returns>The translated value of <paramref name="str"/> or "STRMISS" when untranslated or when an instance of <see cref="TranslationController"/> does not exist or does not have an instance of <see cref="LanguageUnit"/> assigned to <see cref="TranslationController.CurrentLanguage"/> or <see cref="TranslationController.FallbackLanguage"/>.</returns>
 public static string GetString(this TranslationController translationController, StringNames str, params object[] parts)
 {
     return(translationController != null && (translationController.CurrentLanguage != null || translationController.FallbackLanguage != null) ? translationController.GetString(str, parts.Select(p => (Il2CppSystem.Object)p).ToArray()) : "STRMISS");
 }