Skip to content

Commit

Permalink
Localization
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Aug 23, 2023
1 parent 40cffc7 commit 499405b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
7 changes: 7 additions & 0 deletions ProjectTemplates/ShinyApp/.template.config/ide.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
},
"isVisible": true
},
{
"id": "localization",
"name":{
"text": "Add Localization (Microsoft.Extensions.Localization)"
},
"isVisible": true
},
{
"id": "configuration",
"name": {
Expand Down
11 changes: 11 additions & 0 deletions ProjectTemplates/ShinyApp/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
"description": "Add Shiny Framework by Allan Ritchie - Documentation https://github.com/shinyorg/framework - Lots of helpful services like navigation, zero boilerplate MVVM properties, viewmodel validation, localization, viewmodel lifecycles, dialog services, and more",
"displayName": "Add Shiny Framework (Shiny + ReactiveUI + Prism)"
},
"localization":{
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"description": "Add Localization (Microsoft.Extensions.Localization)",
"displayName": "Add Localization (Microsoft.Extensions.Localization)"
},
"configuration": {
"type": "parameter",
"datatype": "bool",
Expand Down Expand Up @@ -526,6 +533,10 @@
"condition": "(settings == false)",
"exclude": "AppSettings.cs"
},
{
"condition": "(localization == false)",
"exclude": "MainViewModel.resx"
},
{
"condition": "(usemsalbasic == false && usemsalb2c == false)",
"exclude": "Platforms/Android/MsalActivity.cs"
Expand Down
3 changes: 3 additions & 0 deletions ProjectTemplates/ShinyApp/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
global using Prism.Navigation;
global using Prism.Services;
#endif
#if shinyframework || localization
global using Microsoft.Extensions.Localization;
#endif
#if shinyframework || communitytoolkit
global using CommunityToolkit.Maui;
#endif
Expand Down
7 changes: 6 additions & 1 deletion ProjectTemplates/ShinyApp/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ public MainViewModel(BaseServices services) : base(services) {}
#else
public class MainViewModel : NotifyPropertyChanged
{
#if localization
public MainViewModel(IStringLocalizer<MainViewModel> localizer)
{
}
#else
public MainViewModel()
{
}

#endif

string property;
public string Property
Expand Down
18 changes: 18 additions & 0 deletions ProjectTemplates/ShinyApp/MainViewModel.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="LocalizeKey" xml:space="preserve">
<value>This is test localization</value>
</data>
</root>
15 changes: 10 additions & 5 deletions ProjectTemplates/ShinyApp/ShinyApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--#endif-->
<PropertyGroup>
<TargetFrameworks>$(TargetFrameworks);{DOTNET_TFM}-ios</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);{DOTNET_TFM}-android</TargetFrameworks>
<!--#if (usemaccatalyst)-->
<TargetFrameworks>{DOTNET_TFM}-android;{DOTNET_TFM}-ios;{DOTNET_TFM}-maccatalyst</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);{DOTNET_TFM}-maccatalyst</TargetFrameworks>
<!--#else-->
<TargetFrameworks>{DOTNET_TFM}-android;{DOTNET_TFM}-ios</TargetFrameworks>

<!--#endif-->
<OutputType>Exe</OutputType>
<RootNamespace>ShinyApp</RootNamespace>
Expand All @@ -26,7 +28,7 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<ShinyVersion>3.0.0-beta-0273</ShinyVersion>
<ShinyVersion>3.0.0-beta-0277</ShinyVersion>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
Expand Down Expand Up @@ -141,19 +143,22 @@
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="2.0.0" />
<!--#endif-->
<!--#if (usemauimaps)-->
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="7.0.86" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="7.0.92" />
<!--#endif-->
<!--#if (usegooglemaps)-->
<PackageReference Include="Maui.GoogleMaps" Version="5.0.0" />
<!--#endif-->
<!--#if (shinyframework)-->
<PackageReference Include="Prism.DryIoc.Maui" Version="8.1.273-pre" />
<PackageReference Include="ReactiveUI.Fody" Version="19.4.1" />
<PackageReference Include="Shiny.Framework" Version="3.0.0-beta-0008" />
<PackageReference Include="Shiny.Framework" Version="3.0.0-beta-0009" />
<!--#else-->
<PackageReference Include="Shiny.Core" Version="$(ShinyVersion)" />
<PackageReference Include="Shiny.Hosting.Maui" Version="$(ShinyVersion)" />
<!--#endif-->
<!--#if (localization)-->
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.10" />
<!--#endif-->
<!--#if (usemsal)-->
<PackageReference Include="Microsoft.Identity.Client" Version="4.54.0" />
<!--#endif-->
Expand Down

0 comments on commit 499405b

Please sign in to comment.