Skip to content

Commit

Permalink
Implement support for unstranslated strings to GetLocalizedStr
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabboxl committed Nov 24, 2023
1 parent 91bd75b commit 1af317d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions ClassevivaPCTO/Helpers/ResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@ namespace ClassevivaPCTO.Helpers
{
internal static class ResourceExtensions
{
private static ResourceLoader _resLoader = new();
private static ResourceLoader _defaultResLoader = new();

public static string GetLocalizedStr(this string resourceKey)
public static string GetLocalizedStr(this string resourceKey, bool isNotTranslatable = false, string resourceFileName = null)
{
return _resLoader.GetString(resourceKey);
ResourceLoader resLoader = _defaultResLoader;

if (isNotTranslatable)
{
resLoader = new ResourceLoader("untranslatable");
}

if (!string.IsNullOrEmpty(resourceFileName)) {
resLoader = new ResourceLoader(resourceFileName);
}

return resLoader.GetString(resourceKey);
}

public static string GetLocalizedStr(this string resourceKey, string tag)
public static string GetLocalizedStr(this string resourceKey, string tag, bool isNotTranslatable = false, string resourceFileName = null)
{
resourceKey += "_" + tag;
return GetLocalizedStr(resourceKey);
return GetLocalizedStr(resourceKey, isNotTranslatable, resourceFileName);
}
}
}

0 comments on commit 1af317d

Please sign in to comment.