Closed ProbablePrime closed 1 month ago
It would be great if this worked for any other message key, so that one could effectively include single word translations (or certain phrases) into other translation messages - e.g. to dynamically reference whatever the label text of something is without having to remember changing both.
It was something I've wanted for localizing some mod things as well, but which the localization library doesn't seem to offer so far.
@Banane9 Can you elaborate on what you mean?
This change will just, replace {appName} with Resonite in every locations where it is used within Locale Strings. I don't think I understand what you mean by "other message key".
_globalLocaleArguments = new Dictionary<string, object>()
{
{"appName", element.World.Engine.AppName },
{"supportUrl", element.World.Engine.Cloud.Platform.SupportUrl },
{"moderationUrl", element.World.Engine.Cloud.Platform.ModerationUrl }
};
So far our globals :)
EXIT
Can you elaborate on what you mean?
This change will just, replace {appName} with Resonite in every locations where it is used within Locale Strings. I don't think I understand what you mean by "other message key".
As in, rather than having things like {appName} set through globaly applied locale arguments, being able to invoke the content of any other locale message. For example, say you had the following:
"messages": {
"Application.Name": "Resonite",
"General.Save": "Save",
"Dash.Exit.Header": "Exit {Application.Name}",
"Interaction.SaveToInventory": "{General.Save} To Inventory",
}
The second example is perhaps a bit far fetched, but I could see it being used for something like including the name of something in tutorial messages for example. Then there can't be any desync between the actual message and one referring to it.
It would require adding code to the localization library I think, but it should be as easy as falling back to formatting the referenced message into the message, if no argument with that name was found and such a message exists.
Ahh, yesh this would be a separate issue. Nesting is of course possible, but would require additional work.
I can provide some general purpose strings that expose AppName etc. though.
This shipped in 2024.9.4.357
Is your feature request related to a problem? Please describe.
In our Locale files, we frequently have replacement strings for things like the Application Name, or the Support/Moderation URL.
These require manual setup each time they are used which can be frustrating.
Describe the solution you'd like
Add the concept of "Localization Global Variables" which are variables that will always be present within the Localization system.
For example,
{appName}
would be set at a global level within our Localization parser, rather than individually for each string.This allows, any string anywhere in Resonite to make use of
{appName}
without needing code edits.This is particularly useful for business applications where we may need to overwrite appname, with a universe or business specific phrase.
Describe alternatives you've considered
Manually, editing the code base everytime we need to use appName.
Additional Context
Based on work in: https://github.com/Yellow-Dog-Man/Locale/pull/412 by @AirRide91 Required for some B2B work.
Requesters
No response