| @@ -376,6 +376,47 @@ respond to the Interactions within your command modules you need to perform the | |||||
| delegate can be used to create HTTP responses from a deserialized json object string. | delegate can be used to create HTTP responses from a deserialized json object string. | ||||
| - Use the interaction endpoints of the module base instead of the interaction object (ie. `RespondAsync()`, `FollowupAsync()`...). | - Use the interaction endpoints of the module base instead of the interaction object (ie. `RespondAsync()`, `FollowupAsync()`...). | ||||
| ## Localization | |||||
| Discord Slash Commands support name/description localization. Localization is available for names and descriptions of Slash Command Groups ([GroupAttribute]), Slash Commands ([SlashCommandAttribute]), Slash Command parameters and Slash Command Parameter Choices. Interaction Service can be initialized with an `ILocalizationManager` instance in its config which is used to create the necessary localization dictionaries on command registration. Interaction Service has two built-in `ILocalizationManager` implementations: `ResxLocalizationManager` and `JsonLocalizationManager`. | |||||
| ### ResXLocalizationManager | |||||
| `ResxLocalizationManager` uses `.` delimited key names to traverse the resource files and get the localized strings (`group1.group2.command.parameter.name`). A `ResxLocalizationManager` instance must be initialized with a base resource name, a target assembly and a collection of `CultureInfo`s. Every key path must end with either `.name` or `.description`, including parameter choice strings. [Discord.Tools.LocalizationTemplate.Resx](https://www.nuget.org/packages/Discord.Tools.LocalizationTemplate.Resx) dotnet tool can be used to create localization file templates. | |||||
| ### JsonLocalizationManager | |||||
| `JsonLocaliationManager` uses a nested data structure similar to Discord's Application Commands schema. You can get the Json schema [here](https://gist.github.com/Cenngo/d46a881de24823302f66c3c7e2f7b254). `JsonLocalizationManager` accepts a base path and a base file name and automatically discovers every resource file ( \basePath\fileName.locale.json ). A Json resource file should have a structure similar to: | |||||
| ```json | |||||
| { | |||||
| "command_1":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description", | |||||
| "parameter_1":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description" | |||||
| } | |||||
| }, | |||||
| "group_1":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description", | |||||
| "command_1":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description", | |||||
| "parameter_1":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description" | |||||
| }, | |||||
| "parameter_2":{ | |||||
| "name": "localized_name", | |||||
| "description": "localized_description" | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| ``` | |||||
| [AutocompleteHandlers]: xref:Guides.IntFw.AutoCompletion | [AutocompleteHandlers]: xref:Guides.IntFw.AutoCompletion | ||||
| [DependencyInjection]: xref:Guides.DI.Intro | [DependencyInjection]: xref:Guides.DI.Intro | ||||