docs.unity.cn
  • Manual
  • Scripting API
  • Changelog
  • License

Localization 1.0.5

    Show / Hide Table of Contents
    • Localization Package
    • What's new
    • Guides
      • Upgrade guide
      • Installation
      • Quick start guide: 2019.​4+
      • Quick start guide: 2020.​3+
    • Reference
      • Addressables Integration
      • Component Localizers
      • Extensions
        • CSV
        • Google Sheets
          • Sheets Service Provider
          • Configuring Authentication
          • Syncing String Table Collections
        • XLIFF
      • Locale
      • Localization Settings
      • Localized Property Variants
      • Metadata
        • Platform Overrides
      • Platforms
        • Android
        • Editor
        • i​OS
      • Pseudo-Localization
        • Methods
      • Scripting
      • Smart Strings
        • Sources
          • Default
          • Dictionary
          • Persistent Variables
          • List
          • Reflection
          • Value Tuple
          • XML
          • Creating a custom source
        • Formatters
          • Choose
          • Conditional
          • Default
          • Is Match
          • List
          • Plural
          • Sub String
          • Template
          • Time
          • X Element
          • Creating a custom formatter
      • Tables
        • Localization Tables Window
        • String Tables
        • Asset Tables
        • Table Keys
    • Manual
    • Reference
    • Smart Strings
    • Sources
    • Dictionary

    Dictionary source

    The Dictionary source extracts objects with a matching Key from an IDictionary or IDictionary<string, object>.

    When evaluating an IDictionary, if the Key is not a string, the Dictionary source first converts it to a string using the object’s ToString method. The case sensitivity of the comparison is determined by the Smart Form Case Sensitivity option.

    Example Smart String Arguments Result
    {SomeKey}
    new Dictionary<string, object>() { { "SomeKey", 999 } }
    
    999
    Hello {Name} {Surname}
    new Dictionary<string, string>(){ { "Name", "Gordon" }, { "Surname", "Freeman" }, }
    
    Hello Gordon Freeman
    {Name} {Surname} scored {1:Score} points
    new Dictionary<string, string>(){ { "Name", "Gordon" }, { "Surname", "Freeman" }, },
    new Dictionary<string, object>() { { "Score", 153 } }
    
    Gordon Freeman scored 153 points

    The following example shows how a dictionary could be provided as an argument.

    var localizedString = new LocalizedString("My Table", "My Table Entry");
    var dict = new Dictionary<string, string> { { "Name", "Gordon" }, { "Surname", "Freeman" } };
    localizedString.Arguments = new object[] { dict };
    
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Thursday, October 28, 2021