# Localization
Class
## About
`Localization` is a one-time loader for translated locale packs. It writes translated strings into the existing public `Text...` properties, so drawing and interaction continue to use direct properties without localization dictionary lookups.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Apply | target As Object | Integer | Applies localized values to the supplied object's public, writable, Text-prefixed String properties and returns the number of values applied. |
| Constructor | source As String = "" | (None) | Creates an empty localization pack or loads the supplied JSON locale pack. |
| FromJSON | source As String | Boolean | Replaces the pack's language and localized values with the supplied JSON and returns whether the source was valid. |
| SetValue | typeName As String <br> propertyName As String <br> value As String | (None) | Adds or replaces a localized value for a Text-prefixed public String property on the named class. |
| ToJSON | (None) | String | Returns the locale pack as JSON using the language and strings object schema. |
| Value | typeName As String <br> propertyName As String <br> defaultValue As String = "" | String | Returns the localized value for the named class and property, or the supplied default when the pack does not contain it. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Language | String | (None) | Gets or sets the BCP 47 language tag associated with this locale pack. |
## Notes
### JSON Locale Packs
Locale packs contain a BCP 47 `language` and a `strings` object keyed by class name. Each class contains public `Text...` property names and translated String values. Base-class sections are applied before subclass sections.
```json
{
"language": "fr-CA",
"strings": {
"Editor": {
"TextBoldCaption": "Gras",
"TextSpellingMenuCaption": "Orthographe"
}
}
}
```
Unknown classes and non-`Text` properties are ignored. Only public, writable String properties whose names begin with `Text` are applied. Locale packs are parsed transactionally: malformed, oversized, incorrectly typed, or invalid-language packs are rejected without changing the currently loaded translations. Bounded pack, class, property, and value sizes prevent untrusted locale data from consuming unbounded memory. Loading occurs during application setup and does not add dictionary access to rendering.
## Examples
```xojo
Var french As New GraffitiProEditor.Localization
Call french.FromJSON(localeJSON)
Call french.Apply(Editor1)
Call french.Apply(Inspector1)
Editor1.TextServices.Language = french.Language
```