-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourceLoaderExtensions.cs
61 lines (52 loc) · 2.13 KB
/
ResourceLoaderExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ============================================================================
//
// 言語リソースからの文字列取得
// Copyright (C) 2022 by SHINTA
//
// ============================================================================
// ----------------------------------------------------------------------------
// 以下のパッケージがインストールされている前提
// Serilog.Sinks.File
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// アプリは CSV to resw を使用するので、本クラスはライブラリ用。
// ----------------------------------------------------------------------------
// ============================================================================
// Ver. | 更新日 | 更新内容
// ----------------------------------------------------------------------------
// -.-- | 2022/11/19 (Sat) | 作成開始。
// 1.00 | 2022/11/19 (Sat) | ファーストバージョン。
// (1.01) | 2022/11/19 (Sat) | Serilog の使用を前提にした。
// ============================================================================
using Microsoft.Windows.ApplicationModel.Resources;
namespace Shinta;
internal static class ResourceLoaderExtensions
{
// ====================================================================
// public 関数
// ====================================================================
/// <summary>
/// 文字列取得
/// </summary>
/// <param name="resourceKey"></param>
/// <returns></returns>
public static String ToLocalized(this String resourceKey)
{
try
{
return _resourceLoader.GetString(resourceKey);
}
catch (Exception)
{
Log.Error("言語リソースが見つかりません:" + resourceKey);
return resourceKey;
}
}
// ====================================================================
// private 変数
// ====================================================================
/// <summary>
/// リソース
/// </summary>
private static readonly ResourceLoader _resourceLoader = new();
}