I needed to be able to load translations directly from embedded resources in an assembly without writing them to the disk. Currently, it isn't possible to use the built-in JsonFileLoader & YamlFileLoader to manually load from non-file sources.
This PR implements methods to support loading translations directly from serialized strings, to allow using the parsing capabilities of the built-in file loaders without an actual file.
Added LoadFromString to JsonFileLoader.cs
Added LoadFromString to YamlFileLoader.cs
Renamed fileName parameter in ParseSubElement to source to better describe its purpose (the name also matches the source parameter in LocalizationLoader.AddTranslation)
Fixed comments in YamlFileLoader.cs referring to Json format
Usage example:
string serializedJson = "..."; //< this can come from a stream, file, or anywhere else you can get data from
var jsonFileLoader = new JsonFileLoader();
LocalizationLoader.Instance.FileLanguageLoaders.Add(jsonFileLoader);
jsonFileLoader.LoadFromString(serializedJson, LocalizationLoader.Instance);
I needed to be able to load translations directly from embedded resources in an assembly without writing them to the disk. Currently, it isn't possible to use the built-in
JsonFileLoader
&YamlFileLoader
to manually load from non-file sources.This PR implements methods to support loading translations directly from serialized strings, to allow using the parsing capabilities of the built-in file loaders without an actual file.
LoadFromString
toJsonFileLoader.cs
LoadFromString
toYamlFileLoader.cs
fileName
parameter inParseSubElement
tosource
to better describe its purpose (the name also matches the source parameter inLocalizationLoader.AddTranslation
)YamlFileLoader.cs
referring to Json formatUsage example: