mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-28 11:42:28 +00:00
Add ability to fetch translations for a given language
This commit is contained in:
parent
25731dd84b
commit
a340a77d74
18 changed files with 86 additions and 35 deletions
44
ProjectLighthouse.Localization/BaseLayout.da-DK.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.da-DK.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Forside</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Brugere</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Fotos</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Baner</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.en-UD.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.en-UD.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>ǝɯoH</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>sɹǝs∩</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>soʇoɥԀ</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>slǝʌǝ˥</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.es-MX.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.es-MX.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Inicio</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Usuarios</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Fotos</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Niveles</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.ja-JP.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.ja-JP.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>ホーム</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>ユーザー</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>画像</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>レベル</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.pl-PL.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.pl-PL.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Strona Główna</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Gracze</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Zdjęcia</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Poziomy</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
46
ProjectLighthouse.Localization/BaseLayout.resx
Normal file
46
ProjectLighthouse.Localization/BaseLayout.resx
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Home</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Photos</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Levels</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.ru-RU.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.ru-RU.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Home</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Photos</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Levels</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.sv-SE.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.sv-SE.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>Startsida</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Användare</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Foton</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Banor</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
44
ProjectLighthouse.Localization/BaseLayout.zh-CN.resx
Normal file
44
ProjectLighthouse.Localization/BaseLayout.zh-CN.resx
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
|
||||
PublicKeyToken=b77a5c561934e089
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="header_home" xml:space="preserve">
|
||||
<value>主页</value>
|
||||
<comment>A button on the header that takes you to the landing page.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
<comment>A button on the header that takes you to the user listing.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_photos" xml:space="preserve">
|
||||
<value>Photos</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded photos.</comment>
|
||||
</data>
|
||||
|
||||
<data name="header_slots" xml:space="preserve">
|
||||
<value>Levels</value>
|
||||
<comment>A button on the header that takes you to a list of user-uploaded levels. Levels are internally referred to as "slots".</comment>
|
||||
</data>
|
||||
</root>
|
36
ProjectLighthouse.Localization/LocalizationManager.cs
Normal file
36
ProjectLighthouse.Localization/LocalizationManager.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Localization;
|
||||
|
||||
public static class LocalizationManager
|
||||
{
|
||||
private static readonly string namespaceStr = typeof(LocalizationManager).Namespace ?? "";
|
||||
|
||||
public static string GetLocalizedString(TranslationAreas translationArea, string language, string key)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Attempting to load '{key}' for '{language}' ");
|
||||
#endif
|
||||
|
||||
string resourceBasename = $"{namespaceStr}.{translationArea.ToString()}.{language}";
|
||||
ResourceManager resourceManager = new(resourceBasename, Assembly.GetExecutingAssembly());
|
||||
|
||||
string? localizedString = resourceManager.GetString(key);
|
||||
if (localizedString == null)
|
||||
{
|
||||
#if DEBUG
|
||||
if (Debugger.IsAttached) Debugger.Break();
|
||||
#endif
|
||||
return $"{translationArea.ToString()}.{language}.{key}";
|
||||
}
|
||||
|
||||
return localizedString;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetAvailableLanguages(TranslationAreas translationArea)
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(r => r.StartsWith($"{namespaceStr}.{translationArea.ToString()}"));
|
||||
}
|
||||
}
|
14
ProjectLighthouse.Localization/Program.cs
Normal file
14
ProjectLighthouse.Localization/Program.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace LBPUnion.ProjectLighthouse.Localization;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
Console.WriteLine(LocalizationManager.GetLocalizedString(TranslationAreas.BaseLayout, "en-UD", "header_home"));
|
||||
Console.WriteLine("Available languages:");
|
||||
foreach (string language in LocalizationManager.GetAvailableLanguages(TranslationAreas.BaseLayout))
|
||||
{
|
||||
Console.WriteLine(language);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>LBPUnion.ProjectLighthouse.Localization</RootNamespace>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
6
ProjectLighthouse.Localization/TranslationAreas.cs
Normal file
6
ProjectLighthouse.Localization/TranslationAreas.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace LBPUnion.ProjectLighthouse.Localization;
|
||||
|
||||
public enum TranslationAreas
|
||||
{
|
||||
BaseLayout,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue