Skip to content

Commit

Permalink
Add NuGet readme and version up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Jan 28, 2023
1 parent 72bdeea commit 9dd1b6b
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nuget/Mntone.RWinRT.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>R/WinRT is ease-to-use resources access for MRTCore.</description>
<copyright>Copyright © 2023 mntone</copyright>
<readme>docs\readme.md</readme>
<language>en-US</language>
<tags>Win Windows WinRT WindowsRuntime WinUI WindowsUI WinAppSDK WindowsAppSDK mntone Cpp C++ C# CSharp MRTCore Resources resw Culture Globalization Localization i18n</tags>
<repository type="git" url="https://github.com/mntone/RWinRT.git" branch="main" />
</metadata>
<files>
<!--<file src="readme.txt" />-->
<file target="docs" src="readme.md" />
<file target="license.txt" src="..\LICENSE.txt" />

<file target="build" src="Mntone.RWinRT.props" />
Expand Down
139 changes: 139 additions & 0 deletions nuget/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# R/WinRT for Windows App SDK

R/WinRT is ease-to-use resources access for the MRTCore resource files.

[Source code][source] | [Package (NuGet)][package]

## Getting started

### Install the package

Install the R/WinRT with [NuGet][nuget]:

```cmd
nuget install Mntone.RWinRT
```

## Examples

### [C#/WinRT] Get the resource

Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.

```cs
using System;

namespace RWinRTCsTest
{
class Program
{
static void Main(string[] args)
{
var text = R.HelloWorld.Value;
Console.WriteLine(text); // [Output] Hello, World!
}
}
}
```

### [C#/WinRT] Get the formatted resource

Define "I have {0} apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.

```cs
using System;

namespace RWinRTCsTest
{
class Program
{
static void Main(string[] args)
{
var count = 4;
var fmtText = R.IHaveNApples.Format(4);
Console.WriteLine(fmtText); // [Output] I have 4 apples!
}
}
}
```

### [C#/WinRT] Change current language

Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.

```cs
using System;

namespace RWinRTCsTest
{
class Program
{
static void Main(string[] args)
{
RWinRT.ResourceManager.ChangeLanguage("ja-JP");

var language = R.CurrentLanguage.Value;
Console.WriteLine(language); // [Output] 日本語 (Japanese)
}
}
}
```

### [C++/WinRT] Get the resource

Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.

```cpp
#include <iostream>

#include "res.g.h"

int main() {
ResourceManager<R> manager;
ResourceContext<R> context { manager.Context() };
winrt::hstring text { context.Value<R::HelloWorld>() }; // [Output] Hello, World!
std::cout << text << std::endl;
return 0;
}
```

### [C++/WinRT] Get the formatted resource

Define "I have %d apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.

```cpp
#include <iostream>

#include "res.g.h"

int main() {
ResourceManager<R> manager;
ResourceContext<R> context { manager.Context() };
int count { 4 };
winrt::hstring fmtText { context.Format<R::IHaveNApples>(count) }; // [Output] I have 4 apples!
std::cout << fmtText << std::endl;
return 0;
}
```

### [C++/WinRT] Change current language

Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.

```cpp
#include <iostream>

#include "res.g.h"

int main() {
ResourceManager<R> manager;
ResourceContext<R> context { manager.Context(L"ja-JP") };
winrt::hstring text { context.Value<R::CurrentLanguage>() }; // [Output] 日本語 (Japanese)
std::cout << text << std::endl;
return 0;
}
```

[source]: https://github.com/mntone/RWinRT/tree/main/src
[package]: https://www.nuget.org/packages/Mntone.RWinRT
[nuget]: https://www.nuget.org/
2 changes: 1 addition & 1 deletion src/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RWinRTCopyright>Copyright (c) 2023 $(RWinRTAuthor). All rights reserved.</RWinRTCopyright>
<RWinRTVersionMajor>0</RWinRTVersionMajor>
<RWinRTVersionMinor>0</RWinRTVersionMinor>
<RWinRTVersionPatch>3</RWinRTVersionPatch>
<RWinRTVersionPatch>4</RWinRTVersionPatch>
<RWinRTVersionBuild Condition="$(AngelVersionBuild)==''">$([System.DateTime]::Now.ToString(`yyyy`))</RWinRTVersionBuild>
<RWinRTVersionRevision Condition="$(AngelVersionRevision)==''">$([System.DateTime]::Now.ToString(`MMdd`))</RWinRTVersionRevision>
<RWinRTVersionPreRelease>beta</RWinRTVersionPreRelease>
Expand Down

0 comments on commit 9dd1b6b

Please sign in to comment.