Add translation service for web api

This commit is contained in:
Maxime Adler
2025-02-17 13:49:01 +01:00
parent 7a87e3457b
commit fc7cce4ce6
13 changed files with 81 additions and 68 deletions

View File

@@ -1 +1,19 @@
namespace GameIdeas.Resources;
public class Translations (TranslationService translationService)
{
public string GamesIdeas => translationService.Translate(nameof(GamesIdeas));
}
public static class ResourcesKey
{
private static Translations? _instance;
public static void Initialize(Translations translations)
{
_instance = translations;
}
public static string GamesIdeas => _instance?.GamesIdeas ?? throw new InvalidOperationException("ResourcesKey.GamesIdeas is not initialized.");
}

View File

@@ -7,7 +7,7 @@
<#
var path = Path.GetDirectoryName(Host.TemplateFile);
var localPath = Host.ResolvePath(Path.Combine(path,"../../Server/GameIdeas.API/Files/GameIdeas.fr.json"));
var localPath = Host.ResolvePath(Path.Combine(path,"../../GameIdeas/Server/GameIdeas.WebAPI/Files/GameIdeas.fr.json"));
var json = File.ReadAllText(localPath);
@@ -121,8 +121,8 @@
// Generate the class
#>
using System;
namespace ArgosV2.Resources;
namespace GameIdeas.Resources;
public class Translations (TranslationService translationService)
{
<#

View File

@@ -1,7 +1,7 @@
using System.Globalization;
using System.Text.Json;
namespace ArgosV2.Resources;
namespace GameIdeas.Resources;
public class TranslationService
{