using System.Collections.Generic; namespace UnityEngine.Localization.Pseudo { /// /// The PseudoLocale can be added to a project to enable Pseudo-localization. /// Pseudo-localization is a method for testing internationalization aspects of your game. /// Pseudo-localization can help highlight issues that may occur when translating into different /// languages. For example, it can help to highlight areas where there may not be enough space for /// translated text or where the text is hard coded or built in a way that will be difficult to /// localize(word order). /// /// Typically pseudo-localization can be used to highlight the following issues: /// /// /// /// Text length that is significantly longer than the source language, and does not fit within /// the UI constraints, or which causes text breaks at awkward positions. /// On average, expect an English string to increase in length by 30% when translating to another /// language. /// See , /// /// /// /// /// Vertical height issues caused by Font glyphs that are significantly larger than, or possess /// diacritic marks not found in, the source language, and which may be cut off vertically. /// See /// /// /// /// /// Right-to-left issues from languages for which the reading order is not left-to-right, which is /// especially problematic for user input. /// /// /// /// /// Missing Font characters. Some fonts may have a limited character set that will not accommodate non /// ASCII character sets. See , /// /// /// /// /// Word order issues. Text that is concatenated from multiple strings will often assume the words /// will always follow the same order, however when localized the order may change. /// Pseudo-localization can highlight where text has been constructed in this manner. /// See /// /// /// /// [CreateAssetMenu(menuName = "Localization/Pseudo-Locale", fileName = "Pseudo-Locale(pseudo)")] public class PseudoLocale : Locale { [SerializeReference] List m_Methods = new List { new PreserveTags(), new Expander(), new Accenter(), new Encapsulator() }; /// /// The pseudo localization methods that will be applied to the source text. /// public List Methods => m_Methods; /// /// Create a new instance with default values. /// /// public static PseudoLocale CreatePseudoLocale() { var locale = CreateInstance(); locale.name = nameof(PseudoLocale); return locale; } PseudoLocale() { Identifier = new LocaleIdentifier("en"); } internal void Reset() { foreach (var method in Methods) { if (method is CharacterSubstitutor cs) { cs.m_ReplacementsPosition = 0; } } } /// /// Returns a pseudo-localized string using . /// /// /// public virtual string GetPseudoString(string input) { var message = Message.CreateMessage(input); foreach (var method in Methods) { method?.Transform(message); } var result = message.ToString(); message.Release(); return result; } public override string ToString() => $"Pseudo ({base.ToString()})"; } }