Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

IPostProcessValueLocale

interface in Unity.Localization

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Transforms resolved localization values before they are handed back to the caller.

Implement this on a Locale subclass to post-process the values resolved for that locale, such as a pseudo-locale that accents, expands, or brackets strings to test how a layout copes. ResourceDatabase calls IPostProcessValueLocale.PostProcessValue for resolved string values, after Smart String formatting has run, on both the synchronous and asynchronous paths. The generic signature lets one implementation cover other value types as well. A locale that does not implement this interface leaves resolved values untouched. Mark the implementing locale with SerializableAttribute, because the project's locale list holds locales by managed reference and a type without it deserializes as null.

Additional resources: Locale, ResourceDatabase

A pseudo-locale that brackets every resolved string.

using System;

namespace Unity.Localization.Samples { [Serializable] public class PostProcessValueLocaleExample : Locale, IPostProcessValueLocale { public PostProcessValueLocaleExample() : base("qps-ploc", "Pseudo (bracketed)") { }

public T PostProcessValue<T>(T value) => value is string text ? (T)(object)$"[{text}]" : value; } }

Public Methods

Method Description
PostProcessValue Returns the transformed value, or the value unchanged.